pietlinden (9/12/2013)
The weird thing is that if I used a stored procedure and tried to useIN(@MultivaluedParam)
inside the stored procedure, it would fail.
That should work. That is, if you have a column of which the value is equal to @MultivalueParam, you will get a hit. Else not. And if the column is an integer column and @MultivaluedParam is a string, the risk for a conversion error is considerable.
col IN (@x, @y, @z)
is a shortcut for
col = @x OR col = @y OR col = @z
If that @MultivaluedParam is something like a comma-separated string of values and you want hits on individual values, you need to crack into table format - although it would be a lot easier to use a table-valued parameter to start with. Anyway, this article on my web site gives your plenty of methods to crack that string:
http://www.sommarskog.se/arrays-in-sql-2005.html.
[font="Times New Roman"]Erland Sommarskog, SQL Server MVP, www.sommarskog.se[/font]