Sunday, June 29, 2014

Unpivot, Pivot without Aggregation


Thank you.


I helps but I have seems I need little different than I thought.



Really Appreciate your help.



How did you get A2,A3 for column2 and column3? as per your sample data it should be A1,A2


Assuming its a typo what you need is this



declare @t table
(
column1 varchar(2),
column2 varchar(2),
column3 varchar(2),
column4 varchar(2),
column5 varchar(2),
column6 varchar(2),
column7 varchar(2),
column8 varchar(2)
)

insert @t
values ('A1','A2','A3','A4','A5','A6','A7','A8')


SELECT Role,Name
FROM @t
UNPIVOT (Name FOR Role IN
(
[Column1],
[Column2],
[Column3],
[Column4],
[Column5],
[Column6],
[Column7],
[Column8]
))u
ORDER BY Role



replace @t with your actual tablename in your case.






Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://ift.tt/19nLNVq http://ift.tt/1iEAj0c


No comments:

Post a Comment