Results 1 to 2 of 2
  1. #1
    knarlyd is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2013
    Posts
    3

    Import only unique rrecords - SQL (or an Append Query) Access 2010

    Im trying to import only unique records but have yet to be able to figure out the correct SQL statement (using Access 2010):

    INSERT INTO [current] ( [First], [Last], Phone, [E-mail address], Alias, [Country/Region], LastName )
    SELECT DISTINCT tblGlobalAddressListImport.First, tblGlobalAddressListImport.Last, tblGlobalAddressListImport.Phone, tblGlobalAddressListImport.[E-mail address], tblGlobalAddressListImport.Alias, tblGlobalAddressListImport.[Country/Region], current.LastName
    FROM tblGlobalAddressListImport LEFT JOIN [current] ON tblGlobalAddressListImport.[Last] = current.[LastName]
    WHERE (((current.LastName) Is Null));

    First off, I think E-mail address would probably be a better field to check for unique values?


    When I run the above statement, I get an error: MS Access can't append all the records...and it didn't add 1600 record(s) to the table due to key violations

    I've removed indexes from all but the "current" table (which has ID as autonumber), checked for primary keys in foreign table.
    Unique is set to No, everywhere I can find, Allowed zero length,Yes

    I've been stuck for a couple weeks+

    Should be easy I think but I don't have hardly any SQL building experience
    Can anyone offer corrections to the statement please?

  2. #2
    NTC is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2009
    Posts
    2,392
    well you are jumbling things together

    make a stand alone Distinct query that runs correctly - leave out the Append until this task is clearly working right. I would use the Query Design View rather than code because it is easier to test stand alone......

    then in regard to your Append problems - first, create that standalone also and use the Distinct Query as the record source; the error message typically is indicative of a data mismatch such as text into a date field...or text into an autonumber field....or duplicates into a field not allowing duplicates...or nulls into a field that has the property 'required'.... basically you might have to set it up field by field; add a field, run the append query, add the next field and then run the append query - - and see which one is the guilty field.... sometimes it just comes down to grunting thru it.....

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 5
    Last Post: 01-09-2014, 10:45 PM
  2. Replies: 6
    Last Post: 10-23-2013, 08:06 AM
  3. Can not import any excel 2010 spreadsheet into access 2010
    By BobsWright in forum Import/Export Data
    Replies: 4
    Last Post: 09-26-2013, 12:44 PM
  4. import table to append to a table in Access 2010
    By Stephanie53 in forum Forms
    Replies: 2
    Last Post: 05-23-2013, 03:40 PM
  5. Access 2003: Import & Append New data
    By compooper in forum Programming
    Replies: 2
    Last Post: 06-22-2011, 08:44 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums