CREATE VIEW Contact_in_222 WITH SCHEMABINDING AS SELECT c.ContactID, title as [Title], lastname as [Last Name], firstname as [First Name], phone as [Phone Number], c3.* FROM Person.Contact c JOIN Sales.ContactCreditCard c2 on c.ContactID = c2. ContactID JOIN Sales.CreditCard c3 on c2.CreditCardID = c3.CreditCardID WHERE phone LIKE ‘222%’

You need to create a new view, and you are planning to use this code:

CREATE VIEW Contact_in_222 WITH SCHEMABINDING AS SELECT c.ContactID, title as [Title], lastname as [Last Name], firstname as [First Name], phone as [Phone Number], c3.* FROM Person.Contact c JOIN Sales.ContactCreditCard c2 on c.ContactID = c2. ContactID JOIN Sales.CreditCard c3 on c2.CreditCardID = c3.CreditCardID WHERE phone LIKE ‘222%’


Answer – Change code to this:

CREATE VIEW Contact_in_222 WITH SCHEMABINDING AS SELECT c.ContactID, title as [Title], lastname as [Last Name], firstname as [First Name], phone as [Phone Number], c3.CreditCardType as [Card Type] FROM Person.Contact c JOIN Sales.ContactCreditCard c2 on c.ContactID = c2. ContactID JOIN Sales.CreditCard c3 on c2.CreditCardID = c3.CreditCardID WHERE phone LIKE ‘222%’
(You can’t index a view that has a wildcard in the SELECT statement; all columns must be called out specifically. Also note, SELECTALL is not an actual option.)