--保存主表 MERGE INTO dbo.DeliveryReceiving AS t USING @ReceiveMainDt AS s ON t.Id=s.id WHEN MATCHED THEN UPDATE SET --一行五个字段 t.Amount=s.Amount,t.OperId=s.OperId,t.OperDate=GETDATE(),t.OperBranchId=s.OperBranchId WHEN NOT MATCHED BY TARGET THEN INSERT (I…