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
 SQL Server 2005 Forums
 Analysis Server and Reporting Services (2005)
 Join two columns data to populate another column

Author  Topic 

Rick_Boston
Starting Member

5 Posts

Posted - 2009-03-19 : 21:04:05
Hi i want to populate a new column with 2 existing ones

For example

The old table looks like this
Column1 Column2
hello1 hello2
hello3 hello4
hello5 hello6

The new table to look like this

NewColumn
Hello1
Hello2
Hello3
Hello4
Hello5
Hello6

I want to merge the old two columns into one new column, the old columns need to go line by line in the new colums

hope this makes sence

Thanks
Rick B

robvolk
Most Valuable Yak

15732 Posts

Posted - 2009-03-19 : 22:52:35
Take a look in Books Online for "UNPIVOT", it does just what you're looking for.
Go to Top of Page

Rick_Boston
Starting Member

5 Posts

Posted - 2009-03-20 : 08:06:54
ok thanks
Rick B
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-03-20 : 10:02:09
or simply do

SELECT Col
FROM
(
SELECT Column1 AS Col FROM Table
UNION ALL
SELECT Column2 FROM Table
)t
ORDER BY Col
Go to Top of Page
   

- Advertisement -