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-26Lines changed: 10 additions & 26 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -277,43 +277,27 @@ Specifies the graph match pattern. For more information about the arguments for
277
277
>[!IMPORTANT]
278
278
> Preview features are meant for testing only and should not be used on production instances or production data. Please also keep a copy of your test data if the data is important.
279
279
>
280
-
> In Azure Synapse Analytics the MERGE command, currently in preview, may, under certain conditions, leave the target table in an inconsistent state, with rows placed in the wrong distribution, causing later queries to return wrong results in some cases. This problem may happen in 2 cases:
281
-
>
282
-
> **Case 1**
280
+
> In Azure Synapse Analytics the MERGE command, currently in preview, may, under certain conditions, leave the target table in an inconsistent state, with rows placed in the wrong distribution, causing later queries to return wrong results in some cases. This problem may happen when these two conditions are met:
281
+
>
283
282
> - The MERGE T-SQL statement was executed on a HASH distributed TARGET table in Azure Synapse SQL database AND
284
283
> - The TARGET table of the MERGE has secondary indices or a UNIQUE constraint.
285
284
>
286
-
> **Case 2**
287
-
> - The MERGE T-SQL statement updated a distribution key column of a HASH distributed table.
288
-
>
289
-
> **Case 1** has been fixed in Synapse SQL version ***10.0.15563.0*** and higher.
285
+
> The problem has been fixed in Synapse SQL version ***10.0.15563.0*** and higher.
290
286
> - To check, connect to the Synapse SQL database via SQL Server Management Studio (SSMS) and run ```SELECT @@VERSION```. If the fix has not been applied, manually pause and resume your Synapse SQL pool to get the fix.
291
287
> - Until the fix has been verified applied to your Synapse SQL pool, avoid using the MERGE command on HASH distributed TARGET tables that have secondary indices or UNIQUE constraints.
292
288
> - This fix doesn't repair tables already affected by the MERGE problem. Use scripts below to identify and repair any affected tables manually.
293
289
>
294
-
> **Case 2** is pending fix.
295
-
> - Until further notice, avoid using the MERGE command to update distribution key columns in HASH distributed tables.
296
-
> - Use the scripts below to identify and repair any affected tables manually.
297
-
>
298
-
> To check which hash distributed tables in a database may be of concern (if used in the Cases above), run this statement
290
+
> To check which hash distributed tables in a database cannot work with MERGE due to this issue, run this statement
299
291
>```sql
300
-
>-- Case 1
301
292
>selecta.name, c.distribution_policy_desc, b.typefromsys.tables a joinsys.indexes b
> To check if a hash distributed table for MERGE is affected by either Case 1 or Case 2, follow these steps to examine if the tables have rows landed in wrong distribution. If 'no need for repair' is returned, this table is not affected.
300
+
> To check if a hash distributed TARGET table for MERGE is affected by this issue, follow these steps to examine if the tables have rows landed in wrong distribution. If 'no need for repair' is returned, this table is not affected.
317
301
>
318
302
>```sql
319
303
> if object_id('[check_table_1]', 'U') is not null
@@ -324,14 +308,14 @@ Specifies the graph match pattern. For more information about the arguments for
324
308
> go
325
309
>
326
310
> create table [check_table_1] with(distribution = round_robin) as
327
-
>select<DISTRIBUTION_COLUMN>as x from<MERGE_TABLE>group by<DISTRIBUTION_COLUMN>;
311
+
>select<DISTRIBUTION_COLUMN>as x from<MERGE_TARGET_TABLE>group by<DISTRIBUTION_COLUMN>;
328
312
> go
329
313
>
330
314
> create table [check_table_2] with(distribution = hash(x)) as
331
315
>select x from [check_table_1];
332
316
>go
333
317
>
334
-
> if not exists(select top 1*from (select<DISTRIBUTION_COLUMN>as x from<MERGE_TABLE> except select x from
318
+
> if not exists(select top 1*from (select<DISTRIBUTION_COLUMN>as x from<MERGE_TARGET_TABLE> except select x from
335
319
> [check_table_2]) as tmp)
336
320
>select'no need for repair'as result
337
321
> else select'needs repair'as result
@@ -352,10 +336,10 @@ Specifies the graph match pattern. For more information about the arguments for
0 commit comments