Showing posts with label empid. Show all posts
Showing posts with label empid. Show all posts

Monday, March 19, 2012

Dynamic IN for query

I want to create a report which uses a query that has a dynamic "in" list.
something like

select * from employee where employeeID in (@.empid)

when I send @.empid = 1,2,3 , it shows a compiler error ,
"syntax error converting the nvarchar value '1,2,3' to a column of data type int'.

any workarounds?Hi,

you can use a function to convert string type CSV into table of integer values (which work for IN). That is of course if you collect the values into string type CSV.

Using a CSV with an IN sub-select|||check booksonline about using sp_executesql..might give you an idea..

hth|||Solved it using the csv funtion, Thank you all.