CREATE FUNCTION [dbo].[fun_Split] ( @str varchar(8000),--要分拆的字符串 @spli varchar(10) --字符串分隔符 ) RETURNS @re TABLE(iStr varchar(8000)) AS BEGIN DECLARE @i int,@splen int SELECT @splen=LEN(@spli) ,@i=CHARINDEX(@spli,@str) WHILE @i>0 BEGIN INSERT INTO @re VALUES(LEFT(@str,@i-1)) SELECT @str=SUBSTRING(@str,@i+@splen,8000),@str) END IF @str<>'''' INSERT INTO @re VALUES(@str) RETURN END