Cannot update identity column 'RowID' in synapse sql

asked 2022-12-22T07:06:23.977+00:00
Sambasiva 1 Reputation point

Hi,

Iam trying to pull data from staging to main table using merge statement along with identity column in main table.

facing the error in synapse dedicated sql pool, Cannot update identity column 'RowID'.

the same is working in azure sql database. but not in azure sql dw.

create table test1(RowID int identity(1,1), [Name] nvarchar(255) ,ID nvarchar(255) )
with (distribution = hash([Name]))

create table test2([Name] nvarchar(255),ID nvarchar(255))
 
merge into test1 as target
using test2 as source
on target.ID = source.ID

when not matched by target then
insert ([Name],[ID]) values (source.Name,source.ID)

when matched then
update set
target.[Name] = source.[Name]
when not matched by source then
delete;

273194-image.png

Azure Synapse Analytics
Azure Synapse Analytics
An Azure analytics service that brings together data integration, enterprise data warehousing, and big data analytics. Previously known as Azure SQL Data Warehouse.
2,598 questions
No comments
{count} votes

1 answer

Sort by: Most helpful
  1. answered 2022-12-22T19:10:04.05+00:00
    BhargavaGunnam-MSFT 7,301 Reputation points Microsoft Employee

    Hello @Sambasiva ,

    Welcome to the MS Q&A platform.

    MERGE in Synapse will not work on tables with Identity columns. This is a known restriction of MERGE in the Synapse.

    https://learn.microsoft.com/en-us/sql/t-sql/statements/merge-transact-sql?view=azure-sqldw-latest&preserve-view=true#remarks

    I see the below feedback request in the synapse discussion forum. I would suggest upvoting & comment on this feedback URL. This allows product teams to prioritize your idea against our existing feature backlog effectively and gives insight into the potential impact of implementing the suggested feature.

    https://feedback.azure.com/d365community/idea/268c0c91-0a25-ec11-b6e6-000d3a4f07b8

    273440-image.png

    Please let me know if you have any further questions.

    ------------------------------

    • Please don't forget to click on 130616-image.png and upvote 130671-image.png button whenever the information provided helps you. Original posters help the community find answers faster by identifying the correct answer. Here is how
    • Want a reminder to come back and check responses? Here is how to subscribe to a notification
    • If you are interested in joining the VM program and help shape the future of Q&A: Here is how you can be part of Q&A Volunteer Moderators