create table test (id int identity(1,1), code char(5))
insert into test (code) values ('a')
insert into test (code) values ('a')
insert into test (code) values ('a')
insert into test (code) values ('b')
insert into test (code) values ('b')
insert into test (code) values ('b')
insert into test (code) values ('c')
insert into test (code) values ('d')
insert into test (code) values ('d')

--Identify the rows
select code from test group by code having count(*) > 1

--Remove the rows
delete test
where id > (
select min(m.id)
from test m
where m.code = test.code
)