www.webdeveloper.com
Results 1 to 2 of 2

Thread: help with a conditional INSERT statement

  1. #1
    Join Date
    Oct 2005
    Location
    West Chester, PA
    Posts
    244

    help with a conditional INSERT statement

    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?

  2. #2
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,529
    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.
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles