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.
| Author |
Topic |
|
brownd92
Starting Member
8 Posts |
Posted - 2005-03-15 : 06:52:31
|
| Hi guys,anyone any ideads on how to do the following?I need to get information from a table in database A using a query and insert it into a table in database B.If the record exists already in database B (by id field) then skip it and only add the new records.Any Ideas?ThanksDavid |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2005-03-15 : 07:35:22
|
| Insert the data into an empty staging table. This is a table that is only intended for importing. Once imported, you can delete all of the matching rows from the staging table and then insert the rest, or use a LEFT JOIN or NOT EXISTS query to insert only the missing rows. Once you're done you clean out the staging table with TRUNCATE TABLE. |
 |
|
|
brownd92
Starting Member
8 Posts |
Posted - 2005-03-15 : 08:20:00
|
| Thanks for that,Worked a charm!David |
 |
|
|
|
|
|