Click here to Skip to main content
15,885,216 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
how to concatinate multiple rows with comma separated single column in sql serevr.
Posted

 
Share this answer
 
SQL
Try this,
SELECT DISTINCT id, STUFF((SELECT ','+ CONVERT(VARCHAR(30), Column2)
             FROM table1 AS S2
             WHERE S1.id = S2.id
             FOR XML PATH('')), 1, 1, '') AS Column_HoldingCommavalues
FROM table1 AS S1
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900