SaveTransaction Method
Cette fonctionnalité sera supprimée dans une prochaine version de Microsoft SQL Server. Évitez d'utiliser cette fonctionnalité dans de nouveaux travaux de développement et prévoyez de modifier les applications qui utilisent actuellement cette fonctionnalité.
The SaveTransaction method marks a point within a transaction, that controls conditional application of the RollbackTransaction method.
Syntaxe
object
.SaveTransaction(
Savepoint
)
Parts
object
Expression that evaluates to an object in the Applies To list.Savepoint
String naming the transaction midpoint. The string must be valid for use as a Microsoft SQL Server identifier.
Prototype (C/C++)
HRESULT SaveTransaction(SQLDMO_LPCSTR SavepointName);
Notes
Any open SQL Server transaction can be committed in its entirety, rolled back in its entirety, or rolled back to a midpoint in the transaction identified by the user. Only work within the transaction unit done after the marking of a midpoint is rolled back to the midpoint when a rollback operation is performed naming the midpoint. After rollback to a midpoint, the transaction is considered open and must be closed by either committing work or rolling back the entire transaction.
Each midpoint within a transaction can be named uniquely and then uniquely referenced in a rollback operation. When a midpoint is not named uniquely, a rollback indicating the point affects that work done within the transaction and occurring after the most recent use of the name.
Notes
SQL Distributed Management Objects (SQL-DMO) implements objects that can be used to automate Microsoft SQL Server administration. Most administrative functions use data definition language (DDL) statements for their implementation. Generally, application-defined transaction units are not respected by DDL. Where SQL Server does not implement transaction space for DDL, SQL-DMO does not extend DDL by defining a transaction space.
In general, use the BeginTransaction, CommitTransaction, and RollbackTransaction methods only when submitting Transact-SQL command batches for execution using methods such as ExecuteImmediate. It is suggested that you do not leave transaction units open, but either commit or roll back the unit when the command batch execution method is complete.