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
转载于:https://www.cnblogs.com/badboy2008/archive/2007/03/18/679214.html