Results 1 to 3 of 3

Thread: Transactions

  1. #1
    Join Date
    Oct 2003
    Posts
    268

    Unanswered: Transactions

    Is there a point to wrapping a single UPDATE or INSERT statement in an explicit TRANSACTION:

    Code:
    BEGIN TRANSACTION
    
    INSERT INTO Table (...) VALUES (...)
    
    COMMIT TRANSACTION
    I understand ACID and concept of transactions. However, I thought they were only necessary for multi-statement operations. I'm maintaining code that does this and am wondering if this is necessary. Does SQL Server guarantee ACID for single statements? Are single UPDATE/INSERT statements prone to race condition like affects without using explicit transactions?

  2. #2
    Join Date
    Oct 2003
    Posts
    268
    Quote Originally Posted by RogerWilco
    Are single UPDATE/INSERT statements prone to race condition like affects without using explicit transactions?
    Found the answer to my question; No they aren't. SQL Server creates implicit transactions around single statements.

  3. #3
    Join Date
    Jul 2003
    Location
    San Antonio, TX
    Posts
    3,662
    Autocommit mode is the default transaction management mode of the Microsoft® SQL Server Database Engine. Every Transact-SQL statement is committed or rolled back when it completes. If a statement completes successfully, it is committed; if it encounters any error, it is rolled back. A connection to an instance of the Database Engine operates in autocommit mode whenever this default mode has not been overridden by either explicit or implicit transactions. Autocommit mode is also the default mode for ADO, OLE DB, ODBC, and DB-Library.
    "The data in a record depends on the Key to the record, the Whole Key, and
    nothing but the Key, so help me Codd."

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •