IF OBJECT_ID('dbo.Split') IS NOT NULL
DROP FUNCTION dbo.Split;
GO
create FUNCTION dbo.Split(@pattern as char, @content AS nvarchar(max)) RETURNS @tb TABLE
(
id int identity(1,1) ,
value nvarchar(max)
)
AS
begin
declare @matchIndex int;
set @matchIndex=charindex(@pattern, @content);
while(@matchIndex>0)
begin
insert into @tb(value) values(substring(@content,1,@matchIndex-1));
set @content=stuff(@content,1,@matchIndex,'');
set @matchIndex=charindex(@pattern, @content);
end
insert into @tb(value) values(@content);
return
end
浙公网安备 33010602011771号