DECLARE @B TABLE(IP VARCHAR(15),TICKETID VARCHAR(15))
INSERT INTO @B
SELECT '1.1.1.1','A' UNION ALL
SELECT '2.2.2.2','A' UNION ALL
SELECT '3.3.3.3','A' UNION ALL
SELECT '4.4.4.4','B'
SELECT TICKETID AS TICKETID,
STUFF(
(SELECT ', ' + CONVERT(VARCHAR,IP) FROM @B T1 WHERE T1.TICKETID = T2.TICKETID FOR XML PATH('')),1,1,''
) AS IP
FROM @B T2 GROUP BY TICKETID
子表中两个字符串相加
最新推荐文章于 2021-04-08 08:39:56 发布