Monday, August 26, 2013

How to use Merge keyword in sql?

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);





No comments:

Post a Comment