传入sql数组字符串,输出table
CREATE function [dbo].[split](@aString varchar(8000),@pattern varchar(10)) returns @temp table([Sid] [int] IDENTITY (1, 1) NOT NULL ,a varchar(100)) --实现split功能 的函数 --说明:@aString,字符串,如a:b:c;@pattern,分隔标志,如 : as begin declare @i int set @aString=rtrim(ltrim(@aString)) set @i=charindex(@pattern,@aString) while @i>=1 begin insert @temp values(left(@aString,@i-1)) set @aString=substring(@aString,@i+1,len(@aString)-@i) set @i=charindex(@pattern,@aString) end if @aString<>'' insert @temp values(@aString) return end