Binds or unbinds a connection to other connections. A bound connection allows two or more connections to participate in the same transaction and share the transaction space until a ROLLBACK TRANSACTION or COMMIT TRANSACTION is issued.
For more information about bound connections, see Bound Connections earlier in this document.
sp_bindsession {'bind_token' | 'NULL'}
where
For more information, see srv_getbindtoken later in this document.
This procedure uses a bind token to bind two or more existing client connections together. A connection is a client executing a command. Multiple cooperating database connections allow sharing of a common transaction lock space by being bound together to share a transaction context and lock space.
Note If a connection involved in a local transaction executes a remote procedure call (RPC) on a remote server with SET REMOTE_PROC_TRANSACTIONS ON, the local transaction is promoted to a distributed transaction by Microsoft Distributed Transaction Coordinator (MS DTC) and an MS DTC session starts. When the transaction is promoted, the bind token changes to a distributed token identification number. Use the changed token identification number.
Unbind from a session either by omitting the bind_token parameter or by passing NULL as the bind_token parameter.
This procedure can be executed through ODBC, DB-LIBRARY functions, or isql.
Important Prior to executing sp_bindsession, you must obtain a bind token by running sp_getbindtoken or the Open Data Services srv_getbindtoken function.
For information about obtaining a bind token, see sp_getbindtoken, later in this document.
For more information about the Microsoft Distributed Transaction Coordinator (MS DTC), see the Guide to Microsoft Distributed Transaction Coordinator.
To obtain and pass a bind token, run sp_getbindtoken prior to executing sp_bindsession for sharing the same lock space. If you obtain a bind token, sp_bindsession will run correctly.