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 Using Bound Connections.
sp_bindsession {'bind_token' | NULL}
0 (success) or 1 (failure)
None
sp_bindsession uses a bind token to bind two or more existing client connections. A connection is a client executing a command. Bound database connections share a transaction context and lock space. If sp_bindsession is given a token that is not currently used by any other active session, that token becomes the token for the session. Another session can be bound to this session using this token.
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. For more information, see your Microsoft Distributed Transaction Coordinator documentation.
Unbind from a session either by omitting bind_token or by passing NULL in bind_token.
sp_bindsession can be executed through ODBC, DB-LIBRARY functions, or the isql utility.
Important Prior to executing sp_bindsession, you must obtain a bind token by running sp_getbindtoken or the Open Data Services srv_getbindtoken function.
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 runs correctly.
Execute permissions default to public role.
This example binds the specified bind token to the current session.
Note The bind token shown in the example was obtained by executing sp_getbindtoken prior to executing sp_bindsession.
USE master
EXEC sp_bindsession 'BP9---5---->KB?-V'<>1E:H-7U-]ANZ'
sp_getbindtoken | System Stored Procedures |
srv_getbindtoken |