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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delete Duplicates from Find Duplicates Query

Status
Not open for further replies.

bethabernathy

Programmer
Jul 13, 2001
254
MX
Hi - Is there a way to delete the Duplicates from a Find Duplicates Query that displays all the Duplicates? What syntax would you use?

Thanks, Beth beth@integratedresourcemgmt.com
 


DELETE * FROM YourTable WHERE EXISTS (your Find Dupe SQL Here);
petersdaniel@hotmail.com
"If A equals success, then the formula is: A=X+Y+Z. X is work. Y is play. Z is keep your mouth shut." --Albert Einstein

 
Hmmmmmmmmmmmmmmmmmm,

Hopefully, you did NOT rush right in and do the above. It will delete ALL of the "Duplicates", leaving behind NO record.

In general, the "De-Dup" process goal, is to remove the "extra" copies. Not ALL of them. For that, you need some additional processing. It CAN be done in pure SQL, but I prefer a VB(A) procedure which loops through the Dup recordset. For each "KeyValue", it finds the first matching rec in the source, and then enters a loop which finds and deleted the REMAINDER of the matching records.

MichaelRed
m.red@att.net

There is never time to do it right but there is always time to do it over
 
Michael,

I always use VBA to loop through the dupe query, and delete all but ONE of the dupes.

U said it could be done using just SQL, how is that done? I assumed the only way was to use code.
Hope this is ok. If not, just let me know.

Nick (Everton Rool OK!)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top