Gouache painting of a shelf of paired teacups with the extra twins gathered in a small red crate below

Delete Duplicate Rows in SQL Server and Keep One Copy

To delete duplicate rows in SQL Server and keep one copy, number the rows in each group with ROW_NUMBER and delete every row after the first. This post finds the duplicates first, previews the rows that will go, and deletes them inside a transaction while saving a copy of what was removed. It ends with a unique index on a cleaned column, so the same address can’t come back.

Read More