ask4help
March 11th, 2007, 12:23 PM
Hi all,
I encountered a problem when selecting using WHERE ... IN ... function.
The sql statement is as below:
"select * from table where id in (@id)"
id column is of integer data type
I passed in a string "1,2,3" into parameter @id, and I get an error saying "Convertion failed when converting nvarchar value '5092, 5093' to data type.
However, when the query is "select * from table where id in (1,2,3)", everything is working fine.
Any idea how to use WHERE ... IN ... function in parameterized sql statement?
Thanks...
I encountered a problem when selecting using WHERE ... IN ... function.
The sql statement is as below:
"select * from table where id in (@id)"
id column is of integer data type
I passed in a string "1,2,3" into parameter @id, and I get an error saying "Convertion failed when converting nvarchar value '5092, 5093' to data type.
However, when the query is "select * from table where id in (1,2,3)", everything is working fine.
Any idea how to use WHERE ... IN ... function in parameterized sql statement?
Thanks...