Ann K
asked on
Merge Statement
Depends. What are you trying to accomplish, what is the schema for all these tables, and when you execute it do you receive any kind of error message? Mind readers we ain't.
try this
MERGE Orders AS O
USING (SELECT order_id FROM NewOrders) AS no
ON (o.order_id = no.order_id)
WHEN MATCHED THEN
UPDATE SET o.ShippingDate = no.ShippingDate,
o.PaymentDate = no.PaymentDate,
o.PaymentAmount = no.PaymentAmount
WHEN NOT MATCHED BY TARGET THEN
INSERT (order_id, CustomerName, ShippingDate,PaymentDate,P aymentAmou nt)
VALUES (no.order_id, no.CustomerName, no.ShippingDate,no.Payment Date,no.Pa ymentAmoun t)
MERGE Orders AS O
USING (SELECT order_id FROM NewOrders) AS no
ON (o.order_id = no.order_id)
WHEN MATCHED THEN
UPDATE SET o.ShippingDate = no.ShippingDate,
o.PaymentDate = no.PaymentDate,
o.PaymentAmount = no.PaymentAmount
WHEN NOT MATCHED BY TARGET THEN
INSERT (order_id, CustomerName, ShippingDate,PaymentDate,P
VALUES (no.order_id, no.CustomerName, no.ShippingDate,no.Payment
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.