How can I delete duplicate records?

Q: I HAVE A TABLE THAT CONTAINS 10 RECORDS in it…and now by mistake, for some reason the same record(s) are being insterted with two duplicates, so that I see 30 records in this table. How can I delete these duplicates without losing my original 10 records? Can you write a query that does this?

Bryan Oliver says: Not that easy. You need to have at least a unique key in the table to remove the record as SQL Server will not allow a deletion to affect multiple rows when there is no unique key.

Take a look at this article.

http://www.sql-server-performance.com/dv_delete_duplicates.asp

One Response to “How can I delete duplicate records?”

  1. SQL Lion Says:

    Thank you so much for the valuable information on removing redundancy from a table. Please follow the link below to get more information on Deleting duplicate records from a table efficiently.
    http://www.sqllion.com/2009/05/delete-duplicate-records/

Leave a Reply