Following is my sample dataset:
ID Prod1 Prod2 Prod3
1 ABC01 CDE02 XYZ03
I want to convert rows to columns and my desired output is:
ID Products
1 ABC01
1 CDE02
1 XYZ03
I tried using UNPIVOT, but my code didn't work:
Select Id, Products
From Sample
UNPIVOT
(
Products
FOR Id IN ([1],[2],[3])
) AS P
Can someone please help me converting these rows to columns for each ID?