Append Query

Stemdriller

Registered User.
Local time
Today, 14:52
Joined
May 29, 2008
Messages
187
Hi

A table with over 2000 records in is the main source table for our Controls Database, it has SalesOrders on etc etc.

I am trying to import fresh data everynight into, and thought an Append Query would be the way forward.

It does work to a degree, but how do I stop it from importing duplicates??

Thanks
 
You would base the source data on a query that joins it to the destination table with a left join on the primary key of both tables but with a where clause that the destination table's primary key is null:

INSERT INTO TableDestination
SELECT TableSource.*
FROM TableSource LEFT JOIN TableDestination ON TableDestination.ID = TableSource.ID WHERE TableDestination.ID Is Null
 
Thanks for the response

Will try it later.

Gareth
 
Another method is to put an index with no duplicates on the field that is the unique identifier. By doing this, you can append as much as you like but the duplicates won't get appended.

Chris
 

Users who are viewing this thread

Back
Top Bottom