select a,b,min(field3) as field3,min(field4) as field4,.....min(fieldN) as fieldN into #temp
from tablename group by a,b truncate table tablenameinsert into tablename select * from #tempdrop table #temp
from tablename group by a,b truncate table tablenameinsert into tablename select * from #tempdrop table #temp
a.id <> (select top 1 id from a d
where d.a = a.a and d.b = a.b order by a,c )
可以达到要求
ID为主键
group by xmmc,xmnr having count(*)>1xmbh是关键字,xmmc和xmnr的组合会重复
go
truncate table tablename
go
insert tablename select * from #temp
go
drop table #temp
go
delete table
select * into table from #table