sp_bindsession

Transact-SQL Reference

Transact-SQL Reference

sp_bindsession

Binds or unbinds a connection to other transactions in the same instance of Microsoft SQL Server 2000. A bound connection allows two or more connections to participate in the same transaction and share the transaction until a ROLLBACK TRANSACTION or COMMIT TRANSACTION is issued.

For more information about bound connections, see Using Bound Connections.

Syntax

sp_bindsession { 'bind_token' | NULL }

Arguments

'bind_token'

Is the token that identifies the transaction originally obtained by using sp_getbindtoken or the Open Data Services srv_getbindtoken function. bind_token is varchar(8000).

Return Code Values

0 (success) or 1 (failure)

Remarks

sp_bindsession uses a bind token to bind two or more existing client connections. These client connections must be on the same instance of SQL Server 2000 from which the binding token was obtained. A connection is a client executing a command. Bound database connections share a transaction and lock space.

A bind token obtained from one instance of SQL Server 2000 cannot be used for a client connection that is on another instance even for DTC transactions. A bind token is valid only locally inside each SQL Server and cannot be shared across multiple instances of SQL Server. For a client connection on another instance of SQL Server, you must obtain a different bind token by executing sp_getbindtoken.

sp_bindsession will fail with an error if it uses a token that is not active.

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 transaction. If you obtain a bind token, sp_bindsession runs correctly.

Permissions

Execute permissions default to public role.

Examples

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'

See Also

sp_getbindtoken

srv_getbindtoken

System Stored Procedures