Delete Duplicate Rows in SQL Server
I was working on a legacy Database with tables that has a lot of records, more than like 1M records.
I noticed some duplicate rows there and I had to do something about this.
After some research I came up with the following code that would delete duplicated rows in a table.
DELETE FROM Table1 WHERE ID NOT IN ( SELECT MAX(ID) FROM Table1 GROUP BY DupCol1, DupCol2, DupCol3 )


Leave a Reply