【发布时间】:2012-04-12 03:44:21
【问题描述】:
我有一个包含 1000 万条记录且没有索引的表,我正在尝试对表进行重复数据删除。我尝试使用 select where 使用左连接或 where 不存在的插入;但每次我收到违反密钥的错误。另一个问题是日志文件变得太大,事务将无法完成。我尝试按照在线建议将恢复设置为简单,但这无济于事。以下是我使用的查询;
insert into temp(profile,feed,photo,dateadded)
select distinct profile,feed,photo,dateadded from original as s
where not exists(select 1 from temp as t where t.profile=s.profile)
这只会产生违反密钥错误。我尝试使用以下内容:
insert into temp(profile,feed,photo,dateadded)
select distinct profile,feed,photo,dateadded from original as s
left outer join temp t on t.profile=s.profile where t.profile is null
在这两种情况下,现在日志文件在事务完成之前就已填满。所以我的主要问题是关于日志文件,我可以通过查询找出重复数据删除。
【问题讨论】:
标签: sql-server-2008