--分割字符串,src源字符串,s分隔符,index分割后要取的位置 SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE FUNCTION f_split ( @src varchar(8000), @s varchar(32), @index int ) returns varchar(100) AS BEGIN declare @temp varchar(1000),@start int,@end int,@len int,@count int set @index=2 set @start=1 set @count=0 set @len=len(@src) while @count<@index begin if @end>@len return '' set @end=charindex(@s,@src,@start) if @end=0 begin set @end=@len+1--return @temp end set @temp=substring(@src,@start,@end-@start) set @count=@count+1 set @start=@end+len(@s) end return @temp END GO
SQLServer2008 split函数
猜你喜欢
转载自cisumer.iteye.com/blog/2306920
今日推荐
周排行