Delete duplicate records in SQL Server
Declare @tbl As table ( iid int, iname varchar(10) ) insert into @tbl values(1,'A') insert into @tbl values(2,'B') insert into @tbl values(3,'C') insert into @tbl values(4,'A') insert into @tbl values(5,'C') 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