The COMMIT TRANSACTION request has no corresponding BEGIN TRANSACTION

  • I executed a script with many commits in in. However, while executing the script together i got a message

    "The COMMIT TRANSACTION request has no corresponding BEGIN TRANSACTION"

    Does that mean the all the SQL statenments after the COMMIT (keyword triggering the message)

    was not executed?

  • I just tried this bit of code, both select statements run, and it gave me the same error as well. So I imagine that whatever you had after the statement did run.

    --begin tran

    select 2

    commit

    select 1

  • How about creating or modifying objects and putting the commit in between?

  • if object_id('tempdb..#totest')is not null drop table #totest

    create table #totest(

    clm1 int

    )

    insert #totest values ('5')

    --begin tran

    select * from #totest

    commit

    alter table #totest

    add clm2 char(1)

    select * from #totest

  • does that mean that the message is just an information and the whole code will execute anyway?

  • It would appear so, at least based on the two situations you asked about so far. If you are curious regarding transactions in general then I would suggest some web searches.

    A little light reading that I found informative:

    BEGIN TRAN

    COMMIT

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply