Wednesday, December 26, 2012

Delete Duplicate Records – Rows and Keeping a row of Duplicate Records

By Using CTE - 

 ;WITH TBLCTE(ID,EmpName,number)
 AS
 (
 SELECT e.ID,e.EmpName,ROW_NUMBER() OVER (PARTITION BY e.ID ORDER BY e.ID) number FROM
 Employee e   
 )
 Delete from TBLCTE where number > 1

No comments:

Post a Comment