如果数据库中的一个表不小心被导入的两次。请问有没有办法删除重复的记录??

原来的表也被我覆盖了。现在一删除就提示键列信息不足 :(
---------------------------------------------------------------

还不如删了 然后重导

可以select distinct * into #t1 from tab go
删除表数据truncate table tab go
insert into tab select * from #t1

---------------------------------------------------------------

把原来的表DISTINCT到临时表中
再把原来的表清空
再把临时表的数据加到原来的表
删除临时表,OK
---------------------------------------------------------------

select distinct * into #t from table1
delete from table1
insert into table1 select * from #t
drop table #t

Published At
Categories with 数据库类
Tagged with
comments powered by Disqus