It can be done in many ways (shown in the order of my personal preferences) :
1. Using XML. See
Re: IN and char versus int Thread #
833306.
2. Using fn_split() function from
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnsqlmag01/html/TreatYourself.asp to convert a list into a table and than use derived table in your select
3. Use dynamic sql.
DECLARE @Sql nvarchar(4000)
SET @Sql = 'SELECT ... WHERE column in (' + @ListParam + ')'
EXECUTE(@Sql)
>I have a procedure that has a SELECT statement in it using the IN predicate.
>
>SELECT ...
> WHERE column in ('11','12',...)
>
>I want to pass the '11','12',... as a parameter to the procedure.
>
>Right now, I end up having 6 different procedure just to handle the dirrefrent IN values.
>
>Can the IN predicate be sed with a variable ?
>
>I do not know if dynamic SQL could bu used, nor how ;-)
--sb--