ÎÒÏëʵÏֵŦÄÜÊÇ°ÑÒ»ÁÐÖÐÓÐ2¸öÃû×ֵĽøÐзָ±ä³É2ÐУ¬²»ÖªµÀÔõôʵÏÖ£¿ SQL code: /* Ãû³Æ£ºfn_splitº¯Êý. ¹¦ÄÜ£ºÊµÏÖ×Ö·û´®·Ö¸ô¹¦Äܵĺ¯Êý */ create function dbo.fn_split(@inputstr varchar(8000), @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 go
--µ÷ÓÃ declare @str as varchar(30) set @str = '1,2,3,4,5'