This script deletes all duplicates from a table. It keeps the first instance of the record, and discards all others. If you want to keep the last instance of the record, use MAX instead of MIN.
The script can be modified very easily to include more/less fields for comparison. I've successfully used this SP to find dupes in over 100 fields. The only requirement is that the table must have a unique ID field.
Creating a PDF from a Stored Procedure in SQL Server
A short but interesting article, the author has figured out a way to create a PDF from a stored procedure without using a third party library.
2019-09-20 (first published: 2003-08-26)
73,245 reads