Deleting Duplicate Records in SQL Table

Declare @tbl As table 
(
iid int,
iname varchar(10)
)  

insert into @tbl values(1,'Kunal')
insert into @tbl values(2,'AKAS')
insert into @tbl values(3,'Kunal')
insert into @tbl values(4,'Paresh')
insert into @tbl values(5,'AKAS')

Select * from @tbl 

Delete From @tbl Where iid in (

Select iid from 
(Select * , ROW_NUMBER() Over ( partition by iname Order by iname ) As ICount  From @tbl)

As Qry Where Qry.ICount > 1
)

Select * from @tbl 
Ebook Download
View all
Learn
View all