摘要:将结果累积串联的最简便方法(FOR XML PATH(''))
示例代码:
SELECT LEFT(RESULT,LEN(RESULT)-1) AS RESULT_VALUE
FROM
(
SELECT
Y+','
FROM (VALUES('01'),('02'),('03'),('04'),('05'),('06'),('07'),('08'),('09'),('10'),('11'),('12')) AS X(Y)
FOR XML PATH('')
) AS A(RESULT);
执行结果: