Controlling Transactions

Discussion in 'SQL Server' started by prashantSum, Sep 15, 2006.

  1. prashantSum

    prashantSum New Member

    Joined:
    Oct 24, 2005
    Messages:
    57
    Likes Received:
    0
    Trophy Points:
    0
    Hi all,
    I want to controll transactions through query analyzer or stored procedure.
    I thought it can be controlled with 'begin transaction' and 'commit' or 'commit transaction' but I am unable achieve with it.

    I have two statements in my stored procedure first one is insert and next one is delete, even if insert is failing delete is getting executed successfully, so how can we controll transactions in MS SQL?
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    Why is the insert failing.
     
  3. prashantSum

    prashantSum New Member

    Joined:
    Oct 24, 2005
    Messages:
    57
    Likes Received:
    0
    Trophy Points:
    0
    I was just testing with it, so I am trying to insert the a record with the same primary key.
    But what ever may be the case, I think transactions should be Atomic.

    I even tried to set auto commit false with
    set auto-commit = false
    but it's giving syntax error
     
  4. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    Transaction is not that way atomic. Transaction gurantees that no other operation can occur in between your transaction on a particular record.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice