Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Using IN

Author  Topic 

kloepper
Yak Posting Veteran

77 Posts

Posted - 2006-03-03 : 16:48:47
I'm having trouble getting an IN clause to work.

When I use a variable to feed the criteria to the clause, the IN fails (no
rows affected). The variable is constructed with a string builder and looks
exactly like the string that works, eg, @symbols = 'adrx', 'aes' .

WHERE (a_Name_Symbol.Symbol IN ('adrx', 'aes')) //This works

WHERE (a_Name_Symbol.Symbol IN (@Symbols)) //This fails

Is there something obvious that I'm doing wrong here?

Paul

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2006-03-03 : 17:13:28
That form of an IN select list is not allowed. You can use dynamic SQL, or you can insert the values into a temp table and use a subquery select in the IN.

CODO ERGO SUM
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2006-03-03 : 17:14:34
http://www.sqlteam.com/item.asp?ItemID=11499

Tara Kizer
aka tduggan
Go to Top of Page

kloepper
Yak Posting Veteran

77 Posts

Posted - 2006-03-03 : 17:33:21
Tara:

Thank you for that answer

Paul
===============================================

quote:
Originally posted by tkizer

http://www.sqlteam.com/item.asp?ItemID=11499

Tara Kizer
aka tduggan

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-03-06 : 01:38:49
Also search for where in @MYCSV here
http://sqlteam.com/forums/topic.asp?TOPIC_ID=55210

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -