When working with databases there are certain tasks that you will find you need to perform regularly. One such task that I find I often need to perform is to delete duplicate records from a database. The following code requires that your table has an identity column, that will be used to identify the duplicate records.

WHERE ID NOT IN (SELECT MAX(ID ) FROM YourTable GROUP BY Column1, Column2, Column3)

The ID column in this example is the identity column and Column1, Column2 and Column3 contain the duplicate data that you want to identify.