selectidentity(int,1,1) as id,*into #tempfrom 用户表 delete #temp where id notin ( selectmax(id) from # groupby col1,col2,col3... ) delete 用户表 ta inset into ta(...) select ..... from #temp
II.用改变表结构(加一个唯一字段)来实现
alter 用户表 add newfield intidentity(1,1) delete 用户表 where newfield notin ( selectmin(newfield) from 用户表 groupby 除newfield外的所有字段 ) alter 用户表 dropcolumn newfield