and a unique index is present and a duplicate row is concurrently
inserted, then a uniqueness violation error is raised;
MERGE does not attempt to avoid such
- errors by evaluating MATCHED conditions.
+ errors by restarting evaluation of MATCHED
+ conditions.
filled with a default value, either its declared default value
or null if there is none.
- If the expression for any column is not of the correct data type,
- automatic type conversion will be attempted.
-
If target_table_name
is a partitioned table, each row is routed to the appropriate partition
MERGE INTO CustomerAccount CA
USING (Select CustomerId, TransactionValue From RecentTransactions) AS T
-ON CA.CustomerId = T.CustomerId
+ON T.CustomerId = CA.CustomerId
+WHEN MATCHED THEN
+ UPDATE SET Balance = Balance + TransactionValue;
WHEN NOT MATCHED THEN
INSERT (CustomerId, Balance)
VALUES (T.CustomerId, T.TransactionValue)
-WHEN MATCHED THEN
- UPDATE SET Balance = Balance + TransactionValue;