Have you ever wondered if there are some commands that can't be part of a SQL named transaction? Well, as a matter...
By submitting your personal information, you agree that TechTarget and its partners may contact you regarding relevant content, products and special offers.
of fact, there are. The restriction comes about because of something called the ACID test. This test defines the properties a Transact-SQL batch statement must have to qualify as a transaction.
ACID stands for:
Atomicity means that changes are either completely made, or are discarded. Consistency refers to leaving all data in a consistent state at the end of a transaction, and that your database maintains its integrity. Isolation makes a transaction separate from and not dependent in any way on another transaction. Finally, durability requires that the completed transaction, once committed, becomes part of the database and is not reversible (except through a complete ROLLBACK, for example).
We don't normally think about these different requirements, as T-SQL will attend to the details for you. Once you complete the BEGIN TRANSACTION / COMMIT TRANSACTION cycle your transaction has the properties of ACID. You can't modify a transaction in progress, although you can ROLLBACK once the transaction is complete. Another feature of a transaction is that in SQL Server, every transaction is a named transaction; something that shows up in the BEGIN TRANSACTION command.
Given these requirements, the following commands cannot be part of a named transaction: ALTER DATABASE, BACKUP LOG, CREATE DATABASE, DROP DATABASE, DUMP TRANSACTION, DISK INIT, LOAD DATABASE, LOAD TRANSACTION, RECONFIGURE, RESTORE DATABASE, RESTORE LOG and UPDATE STATISTICS.
Barrie Sosinsky is president of consulting company Sosinsky and Associates (Medfield MA). He has written extensively on a variety of computer topics.