Where .. IN ...
Database
5
Posts
5
Posters
0
Views
1
Watching
-
-
Hi, Try with two diffrenet integer parameters if your columnID is integer. its working fine 4 me..
Happy Coding... :)
-
You are trying to compare a string '1,3' with an integer field that is not going to work. Either do as Wipin suggested and use 2 variables or change the entire query to dynamic sql
DECLARE @a nvarchar(50)
SET @a = 'select * from tableName where ColumnId in (1,3)'
exec (@a)Never underestimate the power of human stupidity RAH
-
-
I'd advice to not use the "in" operator with a user-defined varchar, but to name the values individually.
SELECT *
FROM tableName
WHERE ColumnId = 1 OR ColumnId = 2You can simply concatenate "OR ColumnId = @value" to the query and set the parameters.
Bastard Programmer from Hell :suss: