Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 convert columns to rows - urgent

Author  Topic 

sqldev_101
Starting Member

1 Post

Posted - 2008-01-13 : 16:55:34
Hi,
I have a table with 5 columns, from that I need only 3 columns , but the columns should be rows in the output
Ex Table 1
col1 col2 col3

Now I want col1 as one row n col2 as 2nd row and col3 as 3rd row

What query should I write to get this?

Will union work


Thank You

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2008-01-13 : 17:06:01
One way is to cross join to a small table to generate the extra rows. Here is an example (from a similar question):
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=95295

Be One with the Optimizer
TG
Go to Top of Page
   

- Advertisement -