TABE1和TABLE2
两个表的表结构相同。TABLE2中的数据比TABLE1中的数据要多
TABLE1中增加TABLE2比TABLE1中多的数据  UPDATE语句 应该怎么写   参照 字段ID  相同的 不更新  TABLE1中没有的 ID 数据 更新进来

解决方案 »

  1.   

    那应该是INSERT吧。。
    insert TABLE1
    select * from (
    select *
    from table2
    except
    select *
    from table1) t
      

  2.   

    --不是用update,应该用insert。
    insert table1 select * from table2  
    where not exists(select 1 from table1,table2 where table1.id=table2.id)
      

  3.   


    insert table1 select * from table2 
    where id not in (select id from table1 where id is not null)insert table1 select * from table2 b 
    where b.id not in (select id from table1 a where a.id=b.id)insert table1 select b.* from table2 b
    outer apply
    (select id from table1 a where a.id=b.id) k
    where k.id is null
      

  4.   


    insert into a 
       select *from b where not exists (select 1 from a where a.字段=b.字段..)
      

  5.   


    insert table1 select * from table2  
    where not exists
    (select 1 from table1where table1.id=table2.id)
      

  6.   


    SQL code
    insert table1 select * from table2  
    where not exists
    (select 1 from table1 where table1.id=table2.id)