affiliate marketing Dot Net Posts: Using CTE and Row_Number() to get the duplicate data in SQL Server 2005

Saturday, 2 July 2011

Using CTE and Row_Number() to get the duplicate data in SQL Server 2005


This is the script to get the duplicate data from employee table, whose employee name is repeating.


With TestData as

(

Select

EmployeeId,

Row_Number() Over( Partition By EmployeeName Order By EmployeeName) AS Rowid

From

Employees

)

Select EmployeeId from TestData Where RowId > 1

No comments:

Post a Comment