Solved

find duplicate records in MS Access

Posted on 2003-11-03
3
886 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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

939 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

10 Experts available now in Live!

Get 1:1 Help Now