Sql server - delete duplicate rows from a table | ASPMANTRA | Asp.Net,MVC,AngularJs,Jquery,Javascript,Sql Server AND WCF snippets and tutorial

Sql server - delete duplicate rows from a table

Introduction: In this article I will explain how we can delete duplicate rows from a table in Sql server


I have a table “Student” and have the duplicate records.

delete duplicate rows from a table

We can delete the duplicate records of table using row_number().
 

with TempTable as
(
select *, row_number() over (partition by name order by name) as Rank
from Student
)
Delete from TempTable where Rank >1

In the above given example I delete the duplicate records on the basis of duplicate name.

delete duplicate rows from a table

In this article I tried to explain Sql server : delete duplicate rows from a table in Sql server. I hope you enjoyed this article. 

Post a Comment

[blogger]

MKRdezign

Contact Form

Name

Email *

Message *

Powered by Blogger.
Javascript DisablePlease Enable Javascript To See All Widget