名称:fn_split函数.
功能:实现字符串分隔功能的函数 --select from f_split('1,2,3,,1,',',') a alter
function
dbo.f_split(@inputstr
varchar(8000),
@seprator varchar(10))
returns @temp table (a varchar(200)) as begin declare @i int
declare @item varchar(200);
set @inputstr = rtrim(ltrim(@inputstr)) set @i = charindex(@seprator , @inputstr) while @i = 1 begin
set @item=rtrim(ltrim(left(@inputstr , @i - 1))); if(@item '')
insert @temp values(@item);
set @inputstr = stuff(@inputstr,1,@i,''); set @i = charindex(@seprator , @inputstr); end
set @item=rtrim(ltrim(@inputstr)); if(@item '')
insert @temp values(@item); return
end
因篇幅问题不能全部显示,请点此查看更多更全内容