I want to pivot a column in SQL Server 2005. I’m pretty sure there is XML way to get it done but can’t figure it out. Here is a table:
ID Class
1 20002
1 20003
1 20004
2 20003
2 20012
Desired value is:
ID Class
1 20002,20003,20004
2 20003,20012
Thanks in advance
I am not sure PIVOT (or UNPIVOT) are what you are looking for. Below is some code that I use when I need to get a CSV list embedded in a query. Hope it helps!