You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/t-sql/statements/merge-transact-sql.md
+10-10Lines changed: 10 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -41,16 +41,6 @@ This article provides different syntax, arguments, remarks, permissions, and exa
41
41
42
42
::: moniker-end
43
43
44
-
> [!TIP]
45
-
> The conditional behavior described for the `MERGE` statement works best when the two tables have a complex mixture of matching characteristics. For example, inserting a row if it doesn't exist, or updating a row if it matches. When simply updating one table based on the rows of another table, improve the performance and scalability with `INSERT`, `UPDATE`, and `DELETE` statements. For example:
46
-
47
-
```sql
48
-
INSERT tbl_A (col, col2)
49
-
SELECT col, col2
50
-
FROM tbl_B
51
-
WHERE NOT EXISTS (SELECT col FROM tbl_A A2 WHEREA2.col=tbl_B.col);
@@ -320,10 +310,20 @@ Specifies the search conditions to specify `<merge_search_condition>` or `<claus
320
310
#### \<graph search pattern>
321
311
322
312
Specifies the graph match pattern. For more information about the arguments for this clause, see [MATCH (Transact-SQL)](../queries/match-sql-graph.md).
313
+
323
314
::: moniker-end
324
315
325
316
## Remarks
326
317
318
+
The conditional behavior described for the `MERGE` statement works best when the two tables have a complex mixture of matching characteristics. For example, inserting a row if it doesn't exist, or updating a row if it matches. When simply updating one table based on the rows of another table, improve the performance and scalability with `INSERT`, `UPDATE`, and `DELETE` statements. For example:
319
+
320
+
```sql
321
+
INSERT tbl_A (col, col2)
322
+
SELECT col, col2
323
+
FROM tbl_B
324
+
WHERE NOT EXISTS (SELECT col FROM tbl_A A2 WHEREA2.col=tbl_B.col);
325
+
```
326
+
327
327
At least one of the three `MATCHED` clauses must be specified, but they can be specified in any order. A variable can't be updated more than once in the same `MATCHED` clause.
328
328
329
329
Any insert, update, or delete action specified on the target table by the `MERGE` statement are limited by any constraints defined on it, including any cascading referential integrity constraints. If `IGNORE_DUP_KEY` is `ON` for any unique indexes on the target table, `MERGE` ignores this setting.
0 commit comments