To delete duplicate records safely, look at them first. The tests here find the duplicates, preview the rows that will go, delete all but the newest copy inside one transaction and add a unique index so they cannot return. Every query ran on SQL Server 2025.
Unique Pairs in Either Order: Blocking A-B When B-A Exists
A plain unique index treats (1, 2) and (2, 1) as different rows. Two computed columns and one index fix that, and I test the awkward cases.
Finding Duplicates Before Adding a Unique Constraint
A unique constraint fails on the first duplicate it meets and tells you about only one. Here is how to list them all and clean up safely.
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.
Matching Two Customer Lists When Names and Emails Are Messy
Clean the text, climb from safe rules to fuzzy ones, and keep one best answer per subscriber. A ladder of joins you can paste into SSMS today.
SQL SERVER – UDF – Remove Duplicate Chars From String
A reader, Virendra Chauhan, shared a UDF that removes duplicate chars from one large string. Here is his REMOVE_DUPLICATE_INSTR function and how to call it.
SQL SERVER – Count Duplicate Records – Rows
A simple query to count duplicate records in a table using GROUP BY, HAVING COUNT(*) and ORDER BY, with the most repeated values first. A video is included.







