Hi,
I have following challenge
Source:
Create Table Foo
(
Col1 Int,
Col2 Int,
Col3 Int
Col4 Int
)
Go
Insert into Foo
Select 10, 70, 30, 90
Output Required
Col1, 10
Col2, 70
Col3, 30
Col4, 90
Rahul
|
|
0
|
|
|
|
Reply
|
Rahul
|
11/23/2009 7:29:46 AM |
|
You can use the UNPIVOT operator:
SELECT col, value
FROM Foo
UNPIVOT
(value FOR col IN (Col1, Col2, Col3, Col4)) AS U;
--
Plamen Ratchev
http://www.SQLStudio.com
|
|
0
|
|
|
|
Reply
|
Plamen
|
11/23/2009 2:46:18 PM
|
|