Invalid object name '##tempusp_GetAsmReports'.\r\nTransaction count after EXECUTE indicates a mismatching number of BEGIN and COMMIT statements. Previous count = 0, current count = 1." 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