Sunday, February 19, 2012

CSV string as a SQL In Parameter

Hi Guys,

I am having SQL query whith "IN"

SELECT * FROM Table1 Where ID in ( 1, 2,3)

how can i pass '1,2,3' as a SP parameter.

Thanks

There is a simple way to resolve this
exec ('select *from tblwhere id in (' + @.csv + ')' )
 
where @.csv is your parameter with comma sparated value.
might this helps you.
 
Thanks
 
|||
Hi, 
There is a simple way to resolve this
exec ('select * from tbl where id in ( ' + @.csv + ')' )
 
where @.csv is your parameter with comma sparated value.
might this helps you.
 
Thanks

No comments:

Post a Comment