Below code works for \'Main Stream\' or \'Premium\' as parameter, however I am trying to make it work for both of them as you can see below, but it doesn\'t return any resul
try:
select id from dbo.split("24,25,26",',');
so you need to to:
select * FROM sales
where myCategory IN ( select id from dbo.split(@myParameter,",");
and add split function in your database by running:
Create FUNCTION [Split](@String varchar(8000), @Delimiter char(1))
returns @temptable TABLE (id varchar(8000))
as
begin
declare @idx int
declare @slice varchar(8000)
select @idx = 1
if len(@String)<1 or @String is null return
while @idx!= 0
begin
set @idx = charindex(@Delimiter,@String)
if @idx!=0
set @slice = left(@String,@idx - 1)
else
set @slice = @String
if(len(@slice)>0)
insert into @temptable(id) values(@slice)
set @String = right(@String,len(@String) - @idx)
if len(@String) = 0 break
end
return
end
Go