MERGE INTO dbo.Customer AS C
USING dbo.CustomerTemp AS CT
ON C.CustomerId = CT.CustomerId
WHEN MATCHED THEN
UPDATE SET
C.CustomerName = CT.CustomerName,
C.Phone = CT.Phone
WHEN NOT MATCHED THEN
INSERT ( CustomerName, Phone)
VALUES ( CT.CustomerName, CT.Phone);
USING dbo.CustomerTemp AS CT
ON C.CustomerId = CT.CustomerId
WHEN MATCHED THEN
UPDATE SET
C.CustomerName = CT.CustomerName,
C.Phone = CT.Phone
WHEN NOT MATCHED THEN
INSERT ( CustomerName, Phone)
VALUES ( CT.CustomerName, CT.Phone);
No comments:
Post a Comment