Another solution that I used and works great:
Create a function in sql server:
CREATE function dbo.CSVTable(@Str varchar(7000))
returns @t table (numberval int, stringval varchar(100), DateVal datetime)
as
begin
declare @i int;
declare @c varchar(100);
set @Str = @Str + ','
set @i = 1;
set @c = '';
while @i <= len(@Str)
begin
if substring(@Str,@i,1) = ','
begin
insert into @t
values (CASE WHEN isnumeric(@c)=1 THEN @c else Null END,
rtrim(ltrim(@c)),
CASE WHEN isdate(@c)=1 then @c else Null END)
set @c = ''
end
else
set @c = @c + substring(@Str,@i,1)
set @i = @i +1
end
return
end
Then in the sp use that function as follows:
where
(@Paramregion IS NULL OR t.region in (Select stringval from dbo.CSVTABLE (@Paramregion)))
|