Skip to main content

Posts

Showing posts from April, 2015

Delete duplicate records from table in single statement (SQL Server)

Deleting duplicate records is very common requirement therefore multiple options are available to delete duplicate records. However this article provides the solution to delete the duplicate records using single statement.

Delete from <TABLE_NAME> where <ID> not in ( select max(<ID>) from TABLE_NAME> group by <DUPLICATE_COLUMN>)


For example:

Employee table
EmpId EmpFullName EmpSalary EmpTitle 1 Sumit Bajaj 5000 Dev 2 Amit 10000 SDev 3