MERGE Orders o
USING Orders2 o2 ON o2.OrderID=o.OrderID
WHEN MATCHED THEN UPDATE SET O.CustomerID=o2.CustomerID--如果匹配到了,就更新掉目标表
WHEN NOT MATCHED THEN INSERT VALUES(o2.OrderID,o2.CustomerID)--如果匹配不到,就插入
WHEN NOT MATCHED BY SOURCE THEN DELETE;--如果来源表无法匹配到,就删除