Results 1 to 9 of 9
Thread: SQL IN operator
Mar 30, 2011, 04:17 #1
SQL IN operator
I want to pass a parameter a string link this:
I want to then use the IN operator to search for any of these number in an ID field which is an INT.
@idsString nvarchar(MAX) SELECT * FROM MyTable WHERE MyTable.IntID IN (idsString)
Msg 245, Level 16, State 1, Procedure pMyProc, Line 30
Conversion failed when converting the nvarchar value '3,4,5' to data type int.
The second issue is that this string may also be empty so I want to do :
@idsString nvarchar(MAX) SELECT * FROM MyTable WHERE MyTable.IntID IN ISNULL((idsString), MyTable.IntID)
cheersmonkey - the rest is history