实现字符串分隔功能的函数
CREATE FUNCTION [dbo].[Func_Split] ( @inputstr VARCHAR(max), @seprator VARCHAR(10) ) RETURNS @temp TABLE (A VARCHAR(200)) AS BEGIN DECLARE @i INT SET @inputstr = RTRIM(LTRIM(@inputstr)) SET @i = CHARINDEX(@seprator , @inputstr) WHILE @i >= 1 BEGIN INSERT @temp VALUES(LEFT(@inputstr , @i - 1)) SET @inputstr = SUBSTRING(@inputstr , @i + 1 , LEN(@inputstr) - @i) SET @i = CHARINDEX(@seprator , @inputstr) END IF @inputstr <> '\' INSERT @temp VALUES(@inputstr) RETURN END