我有两张表
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更新
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更新
FROM [A] a,[B] b
WHERE a.关联列=b.关联列
set e= B.e,f = B.f
from A,B
where A,B的关联条件
如果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
insert A(e,f)
select B.e,B.F
from B
select e,f from B
条件自己加就可以了