Solved

find duplicate records in MS Access

Posted on 2003-11-03
3
884 Views
Last Modified: 2011-09-20
Could anyone can tell me how to find all the duplicate records in a table and delete the duplicate? Thanks a lot!
0
Comment
Question by:omanca
3 Comments
 
LVL 49

Expert Comment

by:Ryan Chong
ID: 9676852
Try something like:

Delete  from table1 where id in

(

Select ID from Table1 Where [referkey] in (
SELECT [referkey] FROM [Table1] As Tmp GROUP BY [referkey] HAVING Count(*)>1
) And iD not in (        

SELECT  Min(ID) AS MinKey from table1 Group by TAble1.referkey

)

)

?
0
 
LVL 77

Accepted Solution

by:
peter57r earned 100 total points
ID: 9676875
It depends on how many records and duplicates you think you have. and what you want to do in the future.

If you start a new query you have a Find Duplicates query wizard which will show you all occurrences of the duplicated records.
If the numbers are small you could then manually delete the unwanted ones.

If you have too many for that then you you can use a trick.

Copy the table containing the duplicates. (Right-click the table name and select copy)
Paste and select Structure only.  Use a name of your choice.

Now modify the design of the copy to prevent any duplicates occuring.
To do this set the primary key or create a unique index based on the fields which  identify the duplication.

Now create an append query which appends records from the original table to the new table.

When you run this query all duplicates will be rejected and you can rename the old and new tables.

Pete




0
 
LVL 2

Author Comment

by:omanca
ID: 9676910
Thanks Pete,
It was good enough to know that there is a "Find Duplicates query wizard"

Omanca
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now