insert into database..tb
  select * from datebase1..tb
  
===================
错误提示.
Cannot insert duplicate key row in object 'tb' with unique index 'tb_1'.
The statement has been terminated.不能删除tb_1

解决方案 »

  1.   

    因为在表中创建了unique index ,该列不允许 insert 重复的值。分析datebase1..tb中的数据,将唯一索引列的重复记录保留一条。
      

  2.   

    是不是“不能删除tb_1”而要插入数据?你需要提供tb_1涉及的字段名insert into database..tb(tb_1涉及的字段名1,tb_1涉及的字段名2...,其他字段,...)
     select tb_1涉及的字段名1,tb_1涉及的字段名2...,其他字段,...
     from datebase1..tb a
     where PK=(select min(PK) from datebase1..tb where tb_1涉及的字段名1=a.tb_1涉及的字段名1 and tb_1涉及的字段名2=a.tb_1涉及的字段名2 ...)
     and not exists (
      select 1 from database..tb where tb_1涉及的字段名1=a.tb_1涉及的字段名1 and tb_1涉及的字段名2=a.tb_1涉及的字段名2 ...)
      

  3.   

    insert into database..tb
      select ss.* from datebase1..tb ss left join database..tb tt where tt.id(任意字段) is null
    估计楼主是这样的表间重复,而不是一个表内部重复,试试看吧