Mike Yearwood
Toronto, Ontario, Canada
General information
Forum:
Microsoft SQL Server
Environment versions
SQL Server:
SQL Server 2008
>>You mean with the IN() clause. Ussually what I do is to put all the keys in a temp table and perform a join with it. Its possible to convert a comma delimited list passed as a parameter into a temp table. Eg
>
>Yes, this is what I am doing now but only if I have a certain number of keys. The IN clause would provide a better and cleaner approach up to a certain number.
I'm sorry. I have to disagree with that.
SELECT * FROM TABLE WHERE FIELD IN (1,2,3,4,5,7,8,9). What number is missing? How long does it take you to determine one is missing? That's just single digit ID's. Why should you have to be concerned with that?
select * from table where field in (select key from userschoices) is much, much cleaner. It provides far more than 32000 keys. If I understand the intent, the user can select many ids - whether you concatenate them into a string or add them to a table - is little difference to the user. But using a single technique - adding them to a table and not trying to decide if you want to use IN in one case and a temp table in another is also much easier on you.
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only