Click to See Complete Forum and Search --> : help with a conditional INSERT statement


aaronbdavis
02-09-2006, 04:22 PM
I have a zip code table which I downloaded from a website in Excel format. I need help on an INSERT script which will look at the Excel table (Imported into Access) and INSERT the row from the Excel table into local Zip Code table unless the entry already exists in the Local table.

Would it be something like "INSERT INTO ZipCodes (zip,city,state,area_code) VALUES (excel.zip,excel.city,excel.state,excel.area_code) IN excel;'?

if I set the Primary Key to zip, then it should ignore the entries that already exist right?

NogDog
02-09-2006, 04:55 PM
Sounds reasonable. I don't know, however, what exactly Access will do if you try to insert a duplicate key: just ignore it or raise an error.