Bobcares

SQL Server Transaction Savepoint | More About

by | Oct 21, 2023

Read the article to learn more about savepoint in SQL Server transactions. At Bobcares, with our SQL Server Support, we can handle your issues.

Savepoint in SQL Server Transaction

Within a transaction, a user has the option to set a savepoint or marker. If a portion of a transaction is conditionally canceled, the savepoint provides a place to which the transaction can return. A transaction that has been rolled back to a savepoint must either continue to its end with more Transact-SQL statements if necessary and a COMMIT TRANSACTION statement, or it must be completely canceled by rolling it back to its start. Use the ROLLBACK TRANSACTION transaction_name form to reverse a complete transaction.

A transaction may have many savepoint names, but only the most recent one using that name will be rolled back by a ROLLBACK TRANSACTION statement that includes the savepoint name.

Unlike some other database systems, SQL Server does not explicitly offer savepoints. However, nested transactions as well as error handling can be used to produce a similar behavior. Also, a savepoint within a transaction can be made using the SAVE TRANSACTION statement.

An Example

sql server transaction savepoint

In this case, we have the option of either rolling back the full transaction or only to the savepoint (MySavePoint) and continuing from there if an error happens during the transaction.

[Looking for a solution to another query? Click here to reach us.]

Conclusion

This article explains briefly about savepoints in SQL Servers by illustrating an example.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Never again lose customers to poor
server speed! Let us help you.