Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
benking9987
Posting Yak Master
124 Posts |
Posted - 2011-11-18 : 17:17:33
|
I have a set of data that looks like this:Column1, Column2Product1, AProduct1, BProduct1, CProduct1, DProduct1, EProduct2, GProduct2, Hetc.I want to manipulate it so it looks like this:Column1, Column2"Product1", "A,B,C,D,E""Product2", "G,H,etc..."Any ideas?Thanks in advance. |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-11-19 : 02:03:09
|
[code]SELECT t.Column1,STUFF((SELECT ',' + Column2 FROM Table1 WHERE Column1 = t.Column1 ORDER BY Column2 FOR XML PATH('')),1,1,'') AS column2FROM (SELECT DISTINCT Column1 FROM Table1)t[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|
|