1
我有一个表与1000万记录与一列上的非聚集索引键,我试图重复表的表。我尝试插入选择使用左连接或不存在;但每次我都会收到违反密钥的错误。以下是我使用的查询;违反主键 - 扣除表
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
我最终使用批量插入因为日志文件增长过大,但仍然得到主键错误的违规甚至只有1000条记录。
Destination Table :IX_Temp - profileUrl(ASC)--> unique key (non clustered)
Source Table: IX_PURL - profileUrl(ASC) ---> index (non clustered, not unique
迁移到http://dba.stackexchange.com/? – 2012-03-29 13:41:15