How to Delete Duplicate records in SQL Server Database? By using CTE.
WITH EmployeeCTE AS (
select *,ROW_NUMBER() OVER(PARTITION BY Eid Order by Eid) as ROWnumber
from Employee
)
delete from EmployeeCTE where ROWnumber>1
Select * from Employee
WITH EmployeeCTE AS (
select *,ROW_NUMBER() OVER(PARTITION BY Eid Order by Eid) as ROWnumber
from Employee
)
delete from EmployeeCTE where ROWnumber>1
Select * from Employee