Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Deleting Repeating Rows

Status
Not open for further replies.

74Stag

Programmer
Joined
Aug 17, 2004
Messages
9
Location
GB
Hi

I need to create a query to delete repeating rows in a table. I need to keep only the rows which do not have any duplicate entries.

For example if I had the following entries:

A
A
B
C
D
D

I need to be left with just:

B
C

Can anyone offer any ideas?
Thanks.
 
Use the Find Duplicates query wizard.
Create the query to list the duplicates.
Change the query type to a Delete query.

Make sure you have a backup.

 
Create a saved maketable query named, say, qryGetDup:
SELECT [yourDupFieldName] INTO tblDup
FROM [yourTable]
GROUP BY [yourDupFieldName]
HAVING Count(*)>1;

Then the purge query:
DELETE FROM [yourTable] INNER JOIN tblDup
ON [yourTable].[yourDupFieldName]=tblDup.[yourDupFieldName];

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thanks for the quick response everyone. They all worked great!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top