有两个数据库DB1,DB2.里面都有一个数据表table(结构相同),现在两个表里都有数据
   现在想把DB1与DB2里不重复的数据拷贝到DB2里去
如何实现?????? 

解决方案 »

  1.   

    insert into DB1.table select distinct * from DB2.table
      

  2.   

    1、说明:复制表(只复制结构,源表名:a 新表名:b) (Access可用) 
    法一:select * into b from a where 1 <>1 
    法二:select top 0 * into b from a 2、说明:拷贝表(拷贝数据,源表名:a 目标表名:b) (Access可用) 
    insert into b(a, b, c) select d,e,f from a; 3、说明:跨数据库之间表的拷贝(具体数据使用绝对路径) (Access可用) 
    insert into b(a, b, c) select d,e,f from b in ‘具体数据库’ where 条件 
    例子:..from b in '"&Server.MapPath(".")&"\data.mdb" &"' where.. 
      

  3.   

    insert into DB2.dbo.table 
    (
    select * from DB1.dbo.table 
    except 
    select * from DB2.dbo.table)
      

  4.   


    insert into db2.dbo.Table 
    select * from db1.dbo.Table
    where id not in(select id  from db2.dbo.Table)
      

  5.   

    insert into DB2.dbo.table 
    (
    select * from DB1.dbo.table 
    except 
    select * from DB2.dbo.table)
      

  6.   

    insert into DB1.table select distinct * from DB2.table
      

  7.   

    dts
    sql:select * from t1 t where not exists(select 1 from t2 where id=t.id)
      

  8.   


    insert into db2.dbo.Table 
    select * from db1.dbo.Table
    where id not in(select id  from db2.dbo.Table)
      

  9.   

    --SQL2005
    insert into DB2.dbo.[table]
    select * 
    from (
    select * from DB1.dbo.[table] 
    except 
    select * from DB2.dbo.[table]
    ) as t--SQL2000:如果表有主键IDinsert into DB2.dbo.[table]
        select * from DB1.dbo.[table] t
        where not exists(
    select 1 
            from DB2.dbo.[table] 
            where id=t.id)
      

  10.   

    insert into DB2.dbo.table 
    select 
    (
    select * from DB1.dbo.table 
    except 
    select * from DB2.dbo.table) tv修改下我上面写的
      

  11.   

    --如果没有自增字段的话,是这样。
    insert db2..tb select  * from db1..tb a where 
    not exists(select 1 from db2..tb where 
    不重复字段1=a.不重复字段1 and 不重复字段2=a.不重复字段2)--依次类推
    --如果有自增字段的话,在字段列表里不加这个字段
      

  12.   

    insert into DB1.table select distinct * from DB2.table