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)
 Insert command help

Author  Topic 

kallileo
Starting Member

21 Posts

Posted - 2008-01-09 : 02:38:45
I have two identical tables in Access and I want to insert the data of second into the first table. I have as Primary Key the column "Registration Number" in both tables. So what else I have to add to the query to insert only the record that have different primary keys.

INSERT INTO db1_table1
SELECT *
FROM db1_table2

nr
SQLTeam MVY

12543 Posts

Posted - 2008-01-09 : 02:54:43
INSERT INTO db1_table1
SELECT db1_table2.*
FROM db1_table2
left join db1_table1
on db1_table2.plk = db1_table1.pk
where db1_table1.pk is null


==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

kallileo
Starting Member

21 Posts

Posted - 2008-01-09 : 03:24:01
Thank you...
Go to Top of Page
   

- Advertisement -