Hi,
In my stored procedure i pass in a CSV list of IDs and use the IN statement to select from them.
However, sometimes i will pass in a blank string and therefore dont want to use the IN clause.
The below logic works correctly when the CSV list is blank -
When i pass a CSV list then i get the following error -
Syntax error converting the varchar value '1108,1109,1110,1111,1112,1113,1114,1115,1116,1117' to a column of data type int.
I understand why im getting the error, does anyone know a way around this?
Rich.
In my stored procedure i pass in a CSV list of IDs and use the IN statement to select from them.
However, sometimes i will pass in a blank string and therefore dont want to use the IN clause.
The below logic works correctly when the CSV list is blank -
Code:
where ((CategoryID in (@CategoryList) and @CategoryList <> '') or (@CategoryList = ''))
When i pass a CSV list then i get the following error -
Syntax error converting the varchar value '1108,1109,1110,1111,1112,1113,1114,1115,1116,1117' to a column of data type int.
I understand why im getting the error, does anyone know a way around this?
Rich.