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
posted @ 2007-03-18 22:48  folen  阅读(297)  评论(0编辑  收藏  举报