Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. @@trancount problem

@@trancount problem

Scheduled Pinned Locked Moved Database
helpquestion
10 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    williamchou
    wrote on last edited by
    #1

    hi, why after execution of 'begin transaction' the @@trancount=2(original value is 0)? thanks!

    V 1 Reply Last reply
    0
    • W williamchou

      hi, why after execution of 'begin transaction' the @@trancount=2(original value is 0)? thanks!

      V Offline
      V Offline
      Venkatraman
      wrote on last edited by
      #2

      When ever a transaction is initiated the @@trancount increases by 1. when a rollback is issued (Even with in nested transaction) the value reset to 0. i am not sure what happens during commit trans (may be it decremented by 1) Cheers, Venkatraman Kalyanam Bangalore - India Reality bites: I am reality

      W 1 Reply Last reply
      0
      • V Venkatraman

        When ever a transaction is initiated the @@trancount increases by 1. when a rollback is issued (Even with in nested transaction) the value reset to 0. i am not sure what happens during commit trans (may be it decremented by 1) Cheers, Venkatraman Kalyanam Bangalore - India Reality bites: I am reality

        W Offline
        W Offline
        williamchou
        wrote on last edited by
        #3

        yes,commit trans decremented by 1,but after this command ,the @@trancount is 1,not 0,the problem is what makes the strange,the @@trancount incremented by 2?

        H 1 Reply Last reply
        0
        • W williamchou

          yes,commit trans decremented by 1,but after this command ,the @@trancount is 1,not 0,the problem is what makes the strange,the @@trancount incremented by 2?

          H Offline
          H Offline
          Hesham Amin
          wrote on last edited by
          #4

          william_zhou wrote: the problem is what makes the strange,the @@trancount incremented by 2? Do you work in Implicit Transactions mode which may be causing this effect ?

          W 2 Replies Last reply
          0
          • H Hesham Amin

            william_zhou wrote: the problem is what makes the strange,the @@trancount incremented by 2? Do you work in Implicit Transactions mode which may be causing this effect ?

            W Offline
            W Offline
            williamchou
            wrote on last edited by
            #5

            no,i assure i had not used this mode

            1 Reply Last reply
            0
            • H Hesham Amin

              william_zhou wrote: the problem is what makes the strange,the @@trancount incremented by 2? Do you work in Implicit Transactions mode which may be causing this effect ?

              W Offline
              W Offline
              williamchou
              wrote on last edited by
              #6

              oh,i'm sorry, i did work in Implicit Transactions mode,but this mode was not setted by me, now how can i cancel this mode

              H 1 Reply Last reply
              0
              • W williamchou

                oh,i'm sorry, i did work in Implicit Transactions mode,but this mode was not setted by me, now how can i cancel this mode

                H Offline
                H Offline
                Hesham Amin
                wrote on last edited by
                #7

                SET IMPLICIT_TRANSACTIONS OFF good luck:)

                W 2 Replies Last reply
                0
                • H Hesham Amin

                  SET IMPLICIT_TRANSACTIONS OFF good luck:)

                  W Offline
                  W Offline
                  williamchou
                  wrote on last edited by
                  #8

                  thanks, but a new problem appears,when i call this proc in my embeded c sql,the return value is -266,which is the same problem @@trancount,i am nearly insane for this bad luck,why?

                  1 Reply Last reply
                  0
                  • H Hesham Amin

                    SET IMPLICIT_TRANSACTIONS OFF good luck:)

                    W Offline
                    W Offline
                    williamchou
                    wrote on last edited by
                    #9

                    i set implicit_transactions off at the beginning of the proc,such as: 'alter proc sp_myproc @i_input as set implicit_transactions declare @tmp int ... ' but when i debug it,i find behind the 'set implicit_transactions' is a strange message:'set implicit_transactions on',now who active this event,why can it happen?

                    H 1 Reply Last reply
                    0
                    • W williamchou

                      i set implicit_transactions off at the beginning of the proc,such as: 'alter proc sp_myproc @i_input as set implicit_transactions declare @tmp int ... ' but when i debug it,i find behind the 'set implicit_transactions' is a strange message:'set implicit_transactions on',now who active this event,why can it happen?

                      H Offline
                      H Offline
                      Hesham Amin
                      wrote on last edited by
                      #10

                      use SET IMPLICIT_TRANSACTIONS OFF before beginning any transactions not inside a transaction. then start the transaction explicitly using BEGIN TRAN

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups