WHERE SomeColumn IN (SELECT SomeColumn From SomeTable)
HTH, Jens K. Suessmeyer.
http://www.sqlserver2005.de|||
Search the forums for "split function". You can then pass values into a stored procedure with a varchar like "2,34,67,98" and have that string split into a set that can be used in an IN clause. These split functions basically break the string up and puts the CSVs into a temporary table and then (similar to the above suggestion) selects the values from the table.
|||But what about doing a select that has results stored in a (single-column) RecordSet? I've not tried it, but can't that RecordSet be passed around as a parameter, and then fed "as is" into an "IN" clause? Is that not a common/popular thing to do? If not, why not?|||>>Is that not a common/popular thing to do?<<
Funny way to put this. Common? Yes. Popular? Yes. Natively supported in SQL Server? Nope.
The "classic" paper on the subject is here: http://www.sommarskog.se/arrays-in-sql.html
You can do it with a table variable, but sadly, you cannot pass this around as a parameter.
No comments:
Post a Comment