Sunday, April 1, 2012

How to delete the duplicates with no primary key in SQLServer 2008

we have wonderful option CTE in SQLServer 2008 and can be used to delete all the duplicate records which are not having primary key. With Duplicate_table (Select Row_number() OVER (partition by ID order BY ID) as RowNumber FROM EMPLOYEE); DELETE FROM Duplicate_Table where RowNumber>1