Insert only unique records

Results 1 to 2 of 2

Thread: Insert only unique records

  1. #1
    Join Date
    Dec 1969

    Default Insert only unique records

    How can I insert only unique records from one database into another database? I have a primary key consisting of 4 fields on my target database, but whenever I run my INSERT if there are any violations, it doesn't insert any records at all. The INSERT statement I'm using is as follows: "INSERT INTO [FHC] IN '0:DATAPAID_CLAIMS.mdb' SELECT * FROM [FHC2]"

  2. #2
    Join Date
    Dec 1969

    Default RE: Insert only unique records

    Try using the &#039;DISTINCT&#039; command in the select statement. For example: SELECT DISTINCT field1, field2, field3, field4 FROM FHC2. The distinct command works for whatever field combination you are selecting. You could also use SELECT DISTINCT * FROM FHC2, but if there are any fields that don&#039;t match, even though the primary key fields match, they will be treated as distinct.<BR>Hope this helps.

Posting Permissions

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