Possible Duplicate:
Parameterizing an SQL IN clause?
SQL:Casting a String to IDS with IN clause
I want to use a declare local variable in a WHERE IN
clause
Something like this:
TABLE XYZ
COL1 COL2
1 A
2 B
3 C
4 D
5 E
RESULT
1 A
2 B
5 E
QUERY
DECLARE @VAR VARCHAR(MAX)
SET @VAR = '1,2,5'
SELECT * FROM XYZ WHERE COL1 IN @VAR
How do I do this?
Note : I cant have a server function
I can only create primitive value (by code) and use it with my query. I search a way that I will only change my var and not the query itself.
my code look like:
list (dbparameter)
mylist.add ('@var','1,2,5')
commandsql.returnresult(myQueryInString,mylist)
I want to