create table test (a char(10),b char(10))
insert test select 'a','1'
insert test select 'b','1'
insert test select 'b','1'
insert test select 'b','1'
insert test select 'a','1'
insert test select 'a','1'
insert test select 'c','1'
insert test select 'c','1'
delete from tablename where id in(select id from tablename a where
(select count(id) as Ts from tablename b where a.id=b.id)>1 )
删除表tablename里的字段ID重读记录
alter table tablename add id int identity(1,1)
go
select *
from tablename a
where exists(select 1 from tablename where col=a.col and id<a.id)
---
select *
from tablename
where id not in(select min(id) from tablename group by col)
go
alter tablename drop column id