Re: Can you use a @variable of strings in a WHERE IN @variable
I have a string of column names. I want to only return results for columns in that list of column names. Can I get the WHERE NOT IN to work or should i parse the list of column names into a table and then use WHERE EXISTS? Do not want to use dynamic SQL.
-- this does not work, but shows what I trying to accomplish declare @string varchar(800) = 'lname,fname' SELECT COLUMN_NAME, ISNULL(Character_maximum_length,0), Data_type FROM [INFORMATION_SCHEMA].[COLUMNS] WHERE TABLE_NAME = 'cust' AND TABLE_SCHEMA='dbo' and COLUMN_NAME not in (@string)