Want to convert column to row in sql server

Posted by Navalemanoj0405 under Sql Server on 6/8/2011 | Points: 10 | Views : 1862 | Status : [Member] | Replies : 3
Dear all

I want to convert column to row in sql server.

this is my sample table
========================

ID Name Address
-- ---- -------
1 abc xxxxxx

2 pqr yyyyyy

3 lmn zzzzzz

4 xyz wwwwww

==========================

want result like this

----------------------------------------------------------------
ID 1 2 3 4


Name abc pqr lmn xyz


Address xxxxxx yyyyyy zzzzzz wwwwww


========================================


please help me.




Responses

Posted by: Susanthampy on: 6/8/2011 [Member] [MVP] Bronze | Points: 25

Up
0
Down
Hi,

Try this,

http://www.logiclabz.com/sql-server/transpose-columns-to-rows-in-sql-server-2005-using-unpivot.aspx

Regards,
Susan

Navalemanoj0405, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sksingh on: 6/9/2011 [Member] Starter | Points: 25

Up
0
Down
Hi,

You can use pivot and unpivot concept of SQL Server.

Regards,
Sunil

Navalemanoj0405, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Susanthampy on: 6/9/2011 [Member] [MVP] Bronze | Points: 25

Up
0
Down
Hi Sunil,

Please explain pivot and unpivot concepts.......

Regards,
Susan

Navalemanoj0405, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response