SQL split
代码
CREATE FUNCTION [dbo].[FunSplit] (@SourceSql varchar(max),@StrSeprate varchar(10))
returns @temp table(a varchar(100))
as
begin
declare @i int,@iSplitLen int
set @iSplitLen=datalength(@StrSeprate)
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+@iSplitLen,datalength(@SourceSql)-@i)
set @i=charindex(@StrSeprate,@SourceSql)
end
if @SourceSql<>'\'
insert @temp values(@SourceSql)
return
end
GO
returns @temp table(a varchar(100))
as
begin
declare @i int,@iSplitLen int
set @iSplitLen=datalength(@StrSeprate)
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+@iSplitLen,datalength(@SourceSql)-@i)
set @i=charindex(@StrSeprate,@SourceSql)
end
if @SourceSql<>'\'
insert @temp values(@SourceSql)
return
end
GO
继续追寻。。。。。。