Skip to content

Use RETURNING/OUTPUT clause for UPDATE/DELETE #27547

@roji

Description

@roji

When modifying a row that has database-generated values, we currently use UPDATE+SELECT:

UPDATE [WithSomeDatabaseGenerated] SET [Data2] = @p0
WHERE [Id] = @p1;

SELECT [Data1]
FROM [WithSomeDatabaseGenerated]
WHERE @@ROWCOUNT = 1 AND [Id] = @p1;

We could use the RETURNING clause (SQL Server OUTPUT) to reduce this to one statement, like we're doing for INSERT in #27372. This would also allow removing the transaction.

For SQL Server with triggers, we would keep the above.

Metadata

Metadata

Assignees

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions