Home Forums SQL Server 2005 SQL Server 2005 General Discussion Ideas about Error 266 "Transaction count after EXECUTE indicates that a COMMIT or ROLLBACK TRANSACTION statement is missing. Previous count = 1, current count = 0." RE: Ideas about Error 266 "Transaction count after EXECUTE indicates that a COMMIT or ROLLBACK TRANSACTION statement is missing. Previous count = 1, current count = 0."

  • Another solution to my original problem (unit testing t-sql - continuing after expected error)

    I am surprised this works really - a more reliable check for sql server to make would be "bindtoken after == bindtoken before"

    Because this can lead to total chaos:

    go

    create proc PreserveTrancount as

    begin

    declare @trancount int

    set @trancount = @@trancount

    --

    if (xact_state() <> 0) rollback tran

    --

    while (@@trancount < @trancount) begin tran

    end

    go

    select @@trancount

    exec PreserveTrancount

    select @@trancount

    go

    begin tran

    select @@trancount

    exec PreserveTrancount

    select @@trancount

    rollback tran

    go