Database Management
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesDatabase Management

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 29th, 2003, 08:32 AM
DavidRTG1 DavidRTG1 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Location: Winnipeg
Posts: 16 DavidRTG1 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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

Reply With Quote
  #2  
Old October 29th, 2003, 09:34 AM
DavidRTG1 DavidRTG1 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Location: Winnipeg
Posts: 16 DavidRTG1 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I got it working.. didn't have the naming correct..

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesDatabase Management > Insert Into New


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT