user1141584
user1141584

Reputation: 619

Simple INSERT Query in SQL Server

I m looking to a way to insert into database Table T1 from T2 (append operation_

Table 1 : dbo.t1

col1   col2
----   -----
1       ABC
2       ABCr  
3       ABCs
4       ABCd

Table 2 : dbo.t2

col1   col2
----   -----
7       ABCe
8       ABCy  

Now , table 1 becomes

col1   col2
----   -----
1       ABC
2       ABCr  
3       ABCs
4       ABCd
7       ABCe
8       ABCy  

SQL query , I m using is:

select * 
into dbo.t1
from dbo.t2

I know it would way too simple using #temp table.

I m looking for a way so that I just append the rows from T2 to T1 and keep performance as well. The existing rows of T1 is not touch at all.

Any help would be helpful.

Thanks !!!

Upvotes: 0

Views: 1155

Answers (1)

Adam Plocher
Adam Plocher

Reputation: 14243

Does this answer your question? It will insert all records from Table2 to the end of Table1 (and not touch existing records in Table1)

insert into Table1 (col1, col2) (select col1, col2 from Table2)

Upvotes: 3

Related Questions