@.myList varchar(200)
SELECT column1
FROM table1
WHERE table1.ID IN (@.myList)
When @.myList is a single value, I get no errors. However, when @.myList is a comma separated list like in the message above, I error out. I am using SQL Server 2000.
How else can I build this list of IDs? Thank you in advance for your comments.
--ColonelYou cannot do what you are trying to do. YOu need to use dynamic SQL, or send in a string and use a function to create a table variable and do the operation based upon a select on that table variable.|||I found that my varchar parameter was being sent in with single quotes around it. I removed these, and now my WHERE clause looks like this:
WHERE table1.ID IN (REPLACE(@.myList,'''',NULL))
and it works just fine.
I did not add those quotes to the list of values. I believe that SQL Server adds them to delimit the text. Thank you for your comments.