Skip to content

MergeUI does not include SET IDENTITY_INSERT <tablename> ON prior to MERGE statements that perform INSERTs #24

@lestephane

Description

@lestephane

When I use MergeUI to generate insert + update + delete statements, and the table I generate the statement for has an IDENTITY column, I get a MERGE statement that contains an INSERT

WHEN NOT MATCHED BY TARGET THEN INSERT ([id],...

But here id is an IDENTITY column, so that fails with the error:

[S0001][544] Cannot insert explicit value for identity column in table '<tablename>' when IDENTITY_INSERT is set to OFF.

I could surround the MERGE statement with the statement to allow INSERTs

SET IDENTITY_INSERT <tablename> ON
<MERGE statement>
SET IDENTITY_INSERT <tablename> OFF

But that somehow feels wrong, since the tool itself knows already that it has to generate inserts. I think MergeUI itself should surround SET IDENTITY_INSERT.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions