借用一临时表.select px = identity(int,1,1) , * into tmp from tb order by id select * from tmp
将重复id号的查出,放到其它表中,再处理此数据,删除有重复id号的数据,再将处理好的数据插入原来的表中 再将id号设为主鍵。取出重复id号记录的操作 select * into 保存的表名称 from 表 as A where exists(select count(*) from 表 where id=a.id having count(*)>1)删除重复id号的记录 delete A from 表 as A where exists(select count(*) from 表 where id=a.id having count(*)>1)
select * from tmp
再将id号设为主鍵。取出重复id号记录的操作
select * into 保存的表名称 from 表 as A
where exists(select count(*) from 表 where id=a.id having count(*)>1)删除重复id号的记录
delete A from 表 as A
where exists(select count(*) from 表 where id=a.id having count(*)>1)