October 8, 2013 at 4:02 am
Hi,
I have one row in table like below.
c1 c2 c3 c4
2 4 6 5
now i want result like below
column1 column2
c1 2
c2 4
c3 6
c4 5
Thnak you in advance.
--chalam
October 8, 2013 at 4:06 am
have a look at this
http://stackoverflow.com/questions/560621/sql-convert-column-to-row
October 8, 2013 at 4:13 am
Use PIVOT
_______________________________________________________________
To get quick answer follow this link:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
October 8, 2013 at 4:15 am
Use CROSS APPLY
DECLARE @t TABLE(c1 INT, c2 INT, c3 INT, c4 INT)
INSERT INTO @t(c1,c2,c3,c4)
VALUES(2,4,6,5);
SELECT ca.column1,ca.column2
FROM @t
CROSS APPLY(VALUES('c1',c1),('c2',c2),('c3',c3),('c4',c4)) ca(column1,column2);
____________________________________________________
Deja View - The strange feeling that somewhere, sometime you've optimised this query before
How to get the best help on a forum
http://www.sqlservercentral.com/articles/Best+Practices/61537Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply