Discussion Locked

Combo Find Duplicates and Delete query

0 helpful
6 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
In Access 2000 I have a Customers table with a lot of duplicates. I know how to write a Find Duplicates query and how to write a Delete query. How can I write a query (or more than one query) that will find all the duplicates then delete all but the first instance of the customer record, leaving only unique records? A good answer to this would save me DAYS of work.

6 replies

by donq

I have never tried this but I bet it will work.

Go to your Employees table with duplicates and create a new select query based on it. Bring in all the fields and insure it creates the same recordset found in your Table.

Now switch to SQL Viewand add the word DISTINCT immediately behind SELECT. Rerun the query to insure it produces exactly what you want - if (or when) it does save it as a Make Table Query named EmplUnique.

Make the new table using all the old column names, then delete the Employees Table and rename EmplUnique to Employees.

Hope this works and gives you one more tool via the Make Table query. They have saved my butt many times. Don Quigg

by donq

Sorry - be careful NOT to delete Employees until the new EmplUnique Table exists without duplicates.

Also immediately after you are successful change your new Table structure to disallow duplicates before it is used.

by johnnyextreme

No good, Don. Using the method you described eliminates only about 1/6 of my duplicates. I'm trying to eliminate records with duplicates in the Name and Address fields, but they may have other unique fields like 1 company with 2 fax numbers, or 2 SIC codes, or 2 cities (Milwaukee / South Milwaukee). I do want to keep at least one fax number or SIC code, (or city!)

by kevin brown

Use the count() function to return the number of duplicate values. In the delete query use a for loop to walk throuh (count-1)duplicate records. This will leave you with one customer record.

This discussion is closed to new replies.