SSDT-DevPack icon indicating copy to clipboard operation
SSDT-DevPack copied to clipboard

MergeUI Does not exclude identity columns from update statements (Causes "Cannot update identity column 'X'")

Open lestephane opened this issue 7 years ago • 0 comments

When i use MergeUI to generate inserts + updates + deletes for a specific table of mine with an 'id' identity key, I get some statements that try to UPDATE identity columns, causing a Cannot update identity column 'id'.

Here is an example:

MERGE INTO [dbo].[...]
 AS TARGET
USING (VALUES(...) AS SOURCE(...) ON [SOURCE].[id] = [TARGET].[id]
WHEN NOT MATCHED ...
WHEN MATCHED AND (...) THEN UPDATE
SET [TARGET].[id] = [SOURCE].[id]

Why try to UPDATE [TARGET].[id] to the value of [SOURCE].[id] when the two where identical in the ON part of the MERGE statement?

lestephane avatar Feb 07 '18 12:02 lestephane