Sql server - delete duplicate rows from a table - Free Asp.Net,MVC,AngularJs,Jquery,Javascript,Sql Server,WCF,Entity framework 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. 

What do you think about this article?

If you found this article useful, please share and follow on Facebook, Twitter, Google Plus and other social media websites. To get free updates subscribe to newsletter. Please put your thoughts and feedback in comments section.

Share this

Share on FacebookTweet on TwitterPlus on Google+


EmoticonEmoticon