Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix ExecuteUpdate returning -1 on open connections by setting NOCOUNT OFF#37827

Open
Abde1rahman1 wants to merge 8 commits intodotnet:mainfrom
Abde1rahman1:fix/execute-update-rows-affected
Open

Fix ExecuteUpdate returning -1 on open connections by setting NOCOUNT OFF#37827
Abde1rahman1 wants to merge 8 commits intodotnet:mainfrom
Abde1rahman1:fix/execute-update-rows-affected

Conversation

@Abde1rahman1
Copy link
Contributor

  • I've read the guidelines for contributing and seen the walkthrough
  • I've posted a comment on an issue with a detailed description of how I am planning to contribute and got approval from a member of the team
  • The code builds and tests pass locally (also verified by our automated build checks)
  • Commit messages follow this format:

Summary of the changes

When ExecuteUpdate is called on an already open connection that had a previous operation (like an Insert with identity) which enabled SET NOCOUNT ON, the subsequent ExecuteUpdate returns -1 instead of the actual rows affected. This PR prepends SET NOCOUNT OFF to the generated SQL to ensure the row count is always returned correctly.

Fixes #35535

  • Tests for the changes have been added (for bug fixes / features)
  • Code follows the same patterns and style as existing code in this repo

@Abde1rahman1 Abde1rahman1 requested a review from a team as a code owner March 2, 2026 22:42
@roji
Copy link
Member

roji commented Mar 3, 2026

I'm not sure how this relates to #35535 - that issue doesn't mention ExecuteUpdate and doesn't seem to be about NOCOUNT specifically, but rather about triggers.

Can you show exactly how this fixes #35535 via a minimal repro? If it's unrelated to #35535, please open a separate issue with a minimal repro that shows what this fixes. On that note, I don't see any test in this PR that specifically shows what it fixes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SQL Server: Support INSTEAD OF INSERT triggers

2 participants