create function f_splitStr(
@s varchar(8000), --待分拆的字符串,如'1,11,21,31'
@split varchar(10) --分隔符,如','
)returns @re table(col varchar(50))
as
begin
while charindex(@split,@s)>0
begin
insert @re values(left(@s,charindex(@split,@s)-1))
set @s=stuff(@s,1,charindex(@split,@s),'')
end
insert @re values(@s)
return
end
@s varchar(8000), --待分拆的字符串,如'1,11,21,31'
@split varchar(10) --分隔符,如','
)returns @re table(col varchar(50))
as
begin
while charindex(@split,@s)>0
begin
insert @re values(left(@s,charindex(@split,@s)-1))
set @s=stuff(@s,1,charindex(@split,@s),'')
end
insert @re values(@s)
return
end