Asp.Net

Delete Duplicate Records Query in a SQL Table

In this Article, I am using Common Table Expression and Row Number Function of SQL Server 2008 R2.

SQL Query:
With CTE 
as
(SELECT  [Name]
 ,[City]
 ,ROW_NUMBER() over (partition by Name,Name order by Name) as RowNum
 FROM [Practice].[dbo].[User])
 delete from CTE where RowNum>1

No comments:

Post a Comment