先建一个视图 select count(*) from yourtable group by ID 找出有两条以上记录的数据 再有条件删除
select distinct * into #temp from 表 truncate table 表 insert 表 select * from #temp drop table #temp
或:删除重复的,只留一条:alter table 表 add newfield int identity(1,1)delete 表 where newfield not in( select min(newfield) from 表 group by 除newfield外的所有字段 )alter table 表 drop column newfield
select distinct 字段名 into 临时表 from tablenamedelete from tablenameselect * from 临时表 into tbalename from 临时表drop table 临时表
select count(*) from yourtable group by ID
找出有两条以上记录的数据
再有条件删除
truncate table 表
insert 表 select * from #temp
drop table #temp
where newfield not in(
select min(newfield) from 表 group by 除newfield外的所有字段
)alter table 表 drop column newfield