Transaction count after EXECUTE indicates a mismatching number of BEGIN and COMMIT statements. Previous count = 5, current count = 6 code example

Example: Transaction count after EXECUTE indicates a mismatching number of BEGIN and COMMIT statements. Previous count = 1, current count = 0

The cause of the error is often mismatch of BEGIN and COMMIT as clearly stated by the error. This means using:

Begin Transaction
  Begin
    -- your query here
  End
commit

instead of

Begin
  Begin
    -- your query here
  End
commit

omitting Transaction after Begin causes this error!

Tags:

Sql Example