共用方式為


srv_getbindtoken (Extended Stored Procedure API)

ms164625.note(zh-tw,SQL.90).gif重要事項:
未來的 Microsoft SQL Server 發行版本將不再提供此功能。請勿在新的開發工作中使用此功能,並且儘速修改使用此功能的應用程式。 Use CLR integration instead.

Obtains a bind token of the transaction in the current client session that invokes the extended stored procedure.

The extended stored procedure can then use sp_bindsession to bind any new session it creates against the same server to the existing transaction so that the new session can share the same transaction lock space with the client session that invoked the extended stored procedure.

語法


int srv_getbindtoken (
SRV_PROC*
srvproc
,
char*
bindtoken
);

Arguments

  • srvproc
    Is a pointer to the SRV_PROC structure that is the handle for a particular client connection. The structure contains all the information that the Extended Stored Procedure API library uses to manage communications and data between the application and the client.
  • bindtoken
    Is a pointer to a buffer where the bind token will be copied. The bind token is represented as a null-terminated string. The buffer you specify should be at least 255 bytes in length.

Returns

SUCCEED or FAIL.

備註

To bind an extended stored procedure session to the client session that called it so they share the same transaction lock space

  1. The extended stored procedure calls svr_getbindtoken to get the bind token for the current transaction in the session. The token is returned in the given bindtoken parameter.

  2. The extended stored procedure opens new session(s) against the same server. Inside that session, the extended stored procedure uses the bind token with sp_bindsession to bind the new session to the same transaction. The extended stored procedure can create multiple sessions and bind all the sessions to the same transaction.

  3. A bound session is unbound when the external stored procedure returns or when sp_bindsession is called with an empty string.

    ms164625.note(zh-tw,SQL.90).gif附註:
    Only one bound session at a time can have access to a shared connection. If one session is currently executing a statement at the server or has results pending from the server, no other sessions sharing the same bound connection can gain access to the server until the current session has finished executing the current statement. If a session attempts to gain access to the connection while the server is busy, an error is returned to the conflicting session indicating the connection is in use and the session should retry later.
ms164625.security(zh-tw,SQL.90).gif安全性注意事項:
You should thoroughly review the source code of extended stored procedures, and you should test the compiled DLLs before you install them on a production server. For information about security review and testing, see this Microsoft Web site.

請參閱

其他資源

sp_bindsession (Transact-SQL)
sp_getbindtoken (Transact-SQL)

說明及資訊

取得 SQL Server 2005 協助