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
 Transact-SQL (2005)
 How to merge two table into a single table in SQL

Author  Topic 

itnagaraj
Yak Posting Veteran

70 Posts

Posted - 2010-08-11 : 06:51:38
How to merge two table into a single table in SQL Server using Merge concepts

Table1
-----------
Col1 Col2
------------------
1 Saran

Table2
-----------
Col1 Col2
------------------
2 Raja

Resultant Table
------------------------
Col1 Col2
------------------
1 Saran
2 Raja

Need Help.Very Urgent

V.NAGARAJAN

vaibhavktiwari83
Aged Yak Warrior

843 Posts

Posted - 2010-08-11 : 07:30:26
Merge is the advanced feature of SQL 2008. Not supported in 2005.

Vaibhav T

To walk FAST walk ALONE
To walk FAR walk TOGETHER
Go to Top of Page

itnagaraj
Yak Posting Veteran

70 Posts

Posted - 2010-08-11 : 07:53:12
quote:
Originally posted by vaibhavktiwari83

Merge is the advanced feature of SQL 2008. Not supported in 2005.

Vaibhav T

To walk FAST walk ALONE
To walk FAR walk TOGETHER



I need in 2008 not old version.

V.NAGARAJAN
Go to Top of Page

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2010-08-11 : 08:25:58
You might want to move this thread to the 2008 forum. You put it in a 2005 forum and so people assumed you were using 2005.

Jim

Everyday I learn something that somebody else already knew
Go to Top of Page

vijayisonly
Master Smack Fu Yak Hacker

1836 Posts

Posted - 2010-08-11 : 09:33:41
quote:
Originally posted by itnagaraj

quote:
Originally posted by vaibhavktiwari83

Merge is the advanced feature of SQL 2008. Not supported in 2005.

Vaibhav T

To walk FAST walk ALONE
To walk FAR walk TOGETHER



I need in 2008 not old version.

V.NAGARAJAN


You could use a union while inserting the data into the resultant table.. like ...
declare @t table (Col1 int, Col2 varchar(10))
insert @t
select 1,'Saran'

declare @r table (Col1 int, Col2 varchar(10))
insert @r
select 2,'Raja'

declare @result table (Col1 int, Col2 varchar(10))
insert @result
select Col1,Col2 from @t
union all
select Col1,COl2 from @r

select * from @result
Go to Top of Page
   

- Advertisement -