How to delete duplicate records in sql server.


Sql Query to delete duplicate records

Delete from a 
from (Select ID,Name 
       ,ROW_NUMBER() over (partition by ID,Name order by ID,Name) RowNumber
from tblEmployee) a
where a.RowNumber > 1

One thought on “How to delete duplicate records in sql server.

  1. Babulal Sah

    Delete duplicate records in sql server USING TEMP TABLE.

    SELECT DISTINCT * INTO #TEMP FROM Emp
    TRUNCATE TABLE Emp
    INSERT INTO Emp
    SELECT * FROM #TEMP
    DROP TABLE #TEMP
    SELECT * FROM Emp

Comments are closed.