Поделиться через


BeginTransaction Method

В будущей версии Microsoft SQL Server эта возможность будет удалена. Избегайте использования этой возможности в новых разработках и запланируйте изменение существующих приложений, в которых она применяется.

The BeginTransaction method explicitly marks the start of a transaction unit.

Синтаксис

object
.BeginTransaction ( [ TransactionName ] )

Parts

  • object
    Expression that evaluates to an object in the Applies To list.
  • TransactionName
    Optional. A string naming the transaction.

Prototype (C/C++)

HRESULT BeginTransaction(
SQLDMO_LPCSTR szTransactionName = NULL);

Замечания

Use the BeginTransaction, CommitTransaction, and RollbackTransaction methods to implement application-defined transaction units.

ms140567.note(ru-ru,SQL.90).gifПримечание.
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 by 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.

Applies to:

SQLServer Object