How to Delete Duplicate Row from Database Table in SQL server

1. Write select statement on your table
 
select * from student
if record is like that
 
d1.PNG
 
2. After that write this query:
 
select ROW_NUMBER() over(partition by name order by name) R, name, dob from student

R is Row number
 
d2.PNG
 
3. Finally write query for deleting the duplicate row and execute this query.
 
delete q from(select ROW_NUMBER() over(partition by name order by name) R, name, dob from student)q where R>1
 
4. After the deletion the command table will look like this.
 
d3.PNG
Ebook Download
View all
SQL Jobs
Read by 0 people
Download Now!
Learn
View all