Delete Duplicate Records from Table SQL Server

In this example we show you how to delete Dupllicate records from one line query easily.The table must have identity column(Primary key) which will be used to identify the duplicate records.
In example table has Userid as Identity Column and Columns which have duplicate data are name, email, PhoneNumber.
We also show usage of Group by Clause, Max Aggregate fucntion.

Delete from TblCustomers Where UserId not in
(
Select Max(Userid)  from TblCustomers
Group by name, email, PhoneNumber )

Related Alrticles

FREE!!! Registration