select identity(int,1,1) id,* into #t from aa delete #t where id>(select id from #t b where #t.xh=b.xh) delete aa insert aa select ... from #t
可以使用临时表,select distinct * into #newtable from oldtable delete from oldtable insert into oldtable (字段名)select * from #newtable drop table #newtable
select identity(int,1,1) id,* into #t from aa delete #t where id>(select min(id) as id from #t b where #t.xh=b.xh) delete aa insert aa select ... from #t
select id=identity(int,1,1) ,* into #t from tabledelete from #t where id not in select id=min(id) from #t a inner join #t b on a.xh=b.xh group by xhinsert into aa select 列名 from #t
delete #t where id>(select id from #t b where #t.xh=b.xh)
delete aa
insert aa select ... from #t
delete from oldtable
insert into oldtable (字段名)select * from #newtable
drop table #newtable
delete #t where id>(select min(id) as id from #t b where #t.xh=b.xh)
delete aa
insert aa select ... from #t
select id=min(id) from #t a inner join #t b on a.xh=b.xh group by xhinsert into aa select 列名 from #t
记录里没有id这个字段,怎么办??/