首页 > 代码库 > sql分割字符串

sql分割字符串

DECLARE @str NVARCHAR(MAX);SET @str = aa|bb|cc|dd;DECLARE @n NVARCHAR(100)SET @str += |WHILE LEN(@str) > 1    BEGIN        SET @n = LEFT(@str, CHARINDEX(|, @str))        SET @str = RIGHT(@str, LEN(@str) - LEN(@n))        SET @n = REPLACE(@n, |, ‘‘)        SELECT  @n    END


----------------------------------------------------------------------------------------------------
aa

(1 行受影响)


----------------------------------------------------------------------------------------------------
bb

(1 行受影响)


----------------------------------------------------------------------------------------------------
cc

(1 行受影响)


----------------------------------------------------------------------------------------------------
dd

(1 行受影响)

 

sql分割字符串