
October 29th, 2003, 08:32 AM
|
|
Registered User
|
|
Join Date: Oct 2003
Location: Winnipeg
Posts: 16
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
Insert Into New
I'm looking for a way to insert new records from one database to another. The only problem is there are some records that are the same in both databases and I don't want 2 of the same record in the new database. Is there an SQL statement that will insert none duplicate records and overwrite duplicates? I'm working with 2 databases in Access.
This is what I have come up with so far but its not working.
Code:
INSERT INTO CatalogueNew2 ( PartNum, Level1, Level2, Level3, Level4 )
SELECT PriceUpdate.PartNum, PriceUpdate.Level1, PriceUpdate.Level2, PriceUpdate.Level3, PriceUpdate.Level4
FROM PriceUpdate
WHERE PriceUpdate.PartNum Not Like CatalogueNew2.PartNum;
EDIT: This query shows me what records are not in the new database and need to be added.
Code:
SELECT *
FROM PriceUpdate LEFT JOIN CatalogueNew ON PriceUpdate.PartNumber=CatalogueNew.PartNumber
WHERE CatalogueNew.PartNumber Is Null;
I tried this but it asks for PriceUpdate.PartNum
Code:
INSERT INTO CatalogueNew2 ( PartNum, Level1, Level2, Level3, Level4 )
SELECT PriceUpdate.PartNum, PriceUpdate.Level1, PriceUpdate.Level2, PriceUpdate.Level3, PriceUpdate.Level4
FROM PriceUpdate LEFT JOIN CatalogueNew2 ON PriceUpdate.PartNumber=CatalogueNew2.PartNumber
WHERE CatalogueNew2.PartNumber Is Null;
Thanks for any help!
David
|