Click here to Skip to main content
15,891,372 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How can i do this with t-sql,
I tried to use a pivot but no luck
My Table

one     two     three     four
----------------------------
1       2       3         4


The output i want

column	value
-------------
one	    1
two	    2
three	3
four	4
Posted
Comments
Sergey Alexandrovich Kryukov 20-Aug-15 11:00am    
Member 11824455 20-Aug-15 15:27pm    
thanks, ill read that later
Sergey Alexandrovich Kryukov 20-Aug-15 15:39pm    
You are welcome; please do.
—SA

1 solution

Use UNPIVOT:
SQL
SELECT [column], value FROM MyTable
UNPIVOT(value FOR [column] IN (one, two, three, four)) AS unp
 
Share this answer
 
Comments
Member 11824455 20-Aug-15 15:28pm    
thanks,
OriginalGriff 20-Aug-15 15:49pm    
You're welcome!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900