Possible Duplicate:
Parameterizing an SQL IN clause?
SQL Server SP - Pass parameter for βINβ array list?
In my SP, I am taking string of data from Reference table to get the SQL select filtered.
here is scenario,
Regionids = 2,6,8 I get this value to a string @regions
In my SP i do calculations and atlast have a big SQL to return the data. Based on Calculations, i get date and ids from which to get records. Also I want to restrict rows to above region specified in Reference.
So in my Where clause of the SELECT, AND RG.regionids IN ( @regions )
I get error, Conversion failed when converting the varchar value '2,6,8' to data type int.
How can i accomplish above request?