sql server中分隔字符的凼数
CREATE function dbo.split_string(@LongStr varchar(8000),@SearchStr varchar(10))
returns @t table(s varchar(100))
as
begin
while (charindex(@SearchStr,@LongStr)>0)
begin
insert @t select left(@LongStr,charindex(@SearchStr,@LongStr)-1)
select @LongStr=stuff(@LongStr,1,charindex(@SearchStr,@LongStr),'')
end
insert @t select @LongStr
return
end
returns @t table(s varchar(100))
as
begin
while (charindex(@SearchStr,@LongStr)>0)
begin
insert @t select left(@LongStr,charindex(@SearchStr,@LongStr)-1)
select @LongStr=stuff(@LongStr,1,charindex(@SearchStr,@LongStr),'')
end
insert @t select @LongStr
return
end