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.
when I pass the string I get the error:Code:@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 :
but this won't even compile.Code:@idsString nvarchar(MAX) SELECT * FROM MyTable WHERE MyTable.IntID IN ISNULL((idsString), MyTable.IntID)