有完全相同得2个表,但是一个在本地服务器上面一个在远程服务器上面,我要把这2个表合并了,其中会有重复的但是我有不能让他们重复,怎么做呢?

解决方案 »

  1.   

    1.建立链接服务器,select * into # from (select a.* from tb a union select b.* from serverb.tb b ) tbtest
    truncate table b
    insert into b select * from # 
    drop #
    2.在主键字段上建立唯一索引。这样所有重复的内容不可导入
    3.写一约束,非主键字段全相同的只能出现一条。
      

  2.   

    select * from tabname1 except select * from tabname2 
      

  3.   

    insert into 目标(*)select * from tabname1 except select * from tabname2
      

  4.   

    insert into table select * from  (select * from tab1 union select * from tab2) aa
      

  5.   

    楼上的这种方法就可以吧,用UNION连起来 就行