How to delete duplicate rows from a table

Posted by Kirthiga under Sql Server category on | Points: 40 | Views : 909
create table Test(Nos int)
insert into Test values(10),(20),(20),(30),(40),(40),(50)
select * from Test

--Query to delete duplicate records
;with dup as
select *,ROW_NUMBER()over(partition by nos order by nos)DupNo from Test
)delete from dup where DupNo>1

select * from Test

Comments or Responses

Login to post response