我有两张表
A: a b c d e f
B:  e f z x y在A表中 a b c d都有数据 e f 为NULLB中 e f是A表e f 所需要的数据 z x y可以不管现在把B中的e f插入A中的e f 怎么样插 就是把A表e f 的NULL更新

解决方案 »

  1.   

    update A  set e= B.e,f = B.f from A a,B b where A,B的关联条件
      

  2.   

    UPDATE [A] SET [e]=[B].[e] ,[f]=[B].[f]
    FROM [A] a,[B] b 
    WHERE a.关联列=b.关联列 
      

  3.   

    貌似楼主没有关联的字段。那就虚拟关联字段,用id=identity(int,1,1)
      

  4.   

    update A  
    set e= B.e,f = B.f 
    from A,B 
    where A,B的关联条件 
      

  5.   


    如果A,B两表有关联列的话,就用这中方式。如果没有的话。UPDATE [A] SET [e]=[B].[e] ,[f]=[B].[f]
    FROM (select row_number() over(order by getdate()) as rid,* from [A]) a,
         (select row_number() over(order by getdate()) as [B] b 
    WHERE a.rid=b.rid 
      

  6.   


    insert A(e,f)
    select B.e,B.F
    from B
      

  7.   

    insert into A(e,f)
    select e,f from B
    条件自己加就可以了