Monday, March 19, 2012

Deleting duplicate records in SQL Server

Deleting duplicate records in SQL Server:
WITH emp AS (SELECT ROW_NUMBER ( ) OVER ( PARTITION BY id, firstname ORDER BY id ) AS RNUM FROMtable1 )
--select * from emp
DELETE FROM Emp WHERE RNUM > 1

Enjoy!!!!!!

No comments:

Post a Comment