标签:sql分割字符串 sql拆分字符串 sql编程 sql
create function [dbo].[fn_Split]
(
@SourceSql nvarchar(max),--源分隔字符串
@StrSeprate varchar(10)--分隔符
)
returns @temp table(a nvarchar(max))
as
begin
declare @i int
set @SourceSql=rtrim(ltrim(@SourceSql))
set @i=charindex(@StrSeprate,@SourceSql)
while @i>=1
begin
insert @temp values(left(@SourceSql,@i-1))
set @SourceSql=substring(@SourceSql,@i+1,len(@SourceSql)-@i)
set @i=charindex(@StrSeprate,@SourceSql)
end
if @SourceSql<>‘\‘
insert @temp values(@SourceSql)
return
end
go
标签:sql分割字符串 sql拆分字符串 sql编程 sql
原文地址:http://blog.csdn.net/y_f123/article/details/38344969