declare @Param1 varchar(100)
set @Param1 ='10,20,30,40'
create table #split (field1 varchar(20))
declare @tstr varchar(1000)
set @tstr=@Param1
while charIndex(',',@tstr)>0
begin
insert into #split (field1) values(substring(@tstr,1,charindex(',',@tstr)-1))
set @tstr = substring(@tstr,charindex(',',@tstr)+1, len(@tstr))
end
insert into #split (field1) values(@tstr)
select * from #split
drop table #split
set @Param1 ='10,20,30,40'
create table #split (field1 varchar(20))
declare @tstr varchar(1000)
set @tstr=@Param1
while charIndex(',',@tstr)>0
begin
insert into #split (field1) values(substring(@tstr,1,charindex(',',@tstr)-1))
set @tstr = substring(@tstr,charindex(',',@tstr)+1, len(@tstr))
end
insert into #split (field1) values(@tstr)
select * from #split
drop table #split