AutoCommit Transactions

AutoCommit is the default transaction mode for SQL Server. Each individual T-SQL command automatically commits or rolls back its work at the end of its execution. Each SQL statement is considered to be its own transaction, with begin and end control points implied. Following is an example:

[implied begin transaction]UPDATE account   SET balance = balance + 1000   WHERE account_no = "123456789"[implied commit or rollback transaction]

If an error is present in the execution of the statement, the action is undone (that is, rolled back); if no errors occur, the action is completed, and the changes are saved.

Now let’s consider the banking transaction mentioned at the beginning of this chapter ...

Get Microsoft® SQL Server 2012 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.