Answered Use a List<string> in a WHERE?

  • Tuesday, February 26, 2013 5:13 PM
     
     

    Hello everyone here. I am trying to get data from my database here WHERE Name is not in a List<string> and I cannot figure out how I can do this at all. Is this possible? Thanks in advance for the help, I do very much appreciate it. 

    Thanks,

All Replies

  • Tuesday, February 26, 2013 5:21 PM
     
     Answered

    Derived from SQL Server Books Online IN (Transact-SQL) http://msdn.microsoft.com/en-us/library/ms177682.aspx, example A has:
    WHERE e.JobTitle IN ('Design Engineer', 'Tool Designer', 'Marketing Assistant');

    You should format your string, something like:
    WHERE [Food] NOT IN ('Apple, 'Berry', 'Cherry');


    Rick Byham, Microsoft, SQL Server Books Online, Implies no warranty