Hi Friends,
How to transpose the columns into rows
i want to convert the table which looks like this
ID Name HomePhone WorkPhone Email
1 test1 678364 643733 test1@test.com
2 test2 678344 643553 test2@test.com
to a table which should look like this
ID Name Device
1 test1 678364
1 test1 643733
1 test1 test1@test.com
2 test2 678344
2 test2 643553
2 test2 test2@test.com
Thanks in Advance
Arunkumar
Plamen Ratchev - 29 May 2007 13:37 GMT
Using UNPIVOT in SQL Server 2005:
SELECT ID, Name, Device
FROM Foobar
UNPIVOT
(Device FOR DeviceType IN
(HomePhone, WorkPhone, Email)) AS U;
HTH,
Plamen Ratchev
http://www.SQLStudio.com