https://www.sqlmatters.com/Articles/Converting%20row%20values%20in%20a%20table%20to%20a%20single%20concatenated%20string.aspx
Solution 5 : Using FOR XML PATH
Some of the XML statements introduced in SQL Server 2005 had to implement a means of looping around data in order to produce XML. This solution takes advantage of this, but strips out the XML specific parts to produce the comma separated list.SELECT STUFF((SELECT ',' + Txt
FROM ConcatenationDemo
FOR XML PATH('')) ,1,1,'') AS Txt
No hay comentarios:
Publicar un comentario