sp_posttracertoken (Transact-SQL)

這個程序會在發行者端的交易記錄中公佈一個追蹤 Token,且會起始追蹤延遲統計資料的處理程序。當追蹤 Token 寫入交易記錄時、當記錄讀取器代理程式收取它時,以及當散發代理程式套用它時,會將資訊記錄下來。這個預存程序執行於發行集資料庫的發行者端。如需詳細資訊,請參閱<針對交易式複寫測量延遲並驗證連接>。

主題連結圖示Transact-SQL 語法慣例

語法

sp_posttracertoken [ @publication = ] 'publication' 
    [ , [ @tracer_token_id = ] tracer_token_id OUTPUT
    [ , [ @publisher = ] 'publisher' 

引數

  • [ @publication= ] 'publication'
    這是在測量延遲的發行集名稱。publicationsysname,沒有預設值。
  • [ @publisher= ] 'publisher'
    指定非 Microsoft SQL Server 發行者。publishersysname,預設值是 NULL,SQL Server 發行者不應該指定這個項目。

傳回碼值

0 (成功) 或 1 (失敗)

備註

sp_posttracertoken 用於交易式複寫中。

權限

只有系統管理員 (sysadmin) 固定伺服器角色或 db_owner 固定資料庫角色的成員,才能夠執行 sp_posttracertoken

範例

DECLARE @publication AS sysname;
DECLARE @tokenID AS int;
SET @publication = N'AdvWorksProductTran'; 

USE [AdventureWorks]

-- Insert a new tracer token in the publication database.
EXEC sys.sp_posttracertoken 
  @publication = @publication,
  @tracer_token_id = @tokenID OUTPUT;
SELECT 'The ID of the new tracer token is ''' + 
    CONVERT(varchar,@tokenID) + '''.'
GO

-- Wait 10 seconds for the token to make it to the Subscriber.
WAITFOR DELAY '00:00:10';
GO

-- Get latency information for the last inserted token.
DECLARE @publication AS sysname;
DECLARE @tokenID AS int;
SET @publication = N'AdvWorksProductTran'; 

CREATE TABLE #tokens (tracer_id int, publisher_commit datetime)

-- Return tracer token information to a temp table.
INSERT #tokens (tracer_id, publisher_commit)
EXEC sys.sp_helptracertokens @publication = @publication;
SET @tokenID = (SELECT TOP 1 tracer_id FROM #tokens
ORDER BY publisher_commit DESC)
DROP TABLE #tokens

-- Get history for the tracer token.
EXEC sys.sp_helptracertokenhistory 
  @publication = @publication, 
  @tracer_id = @tokenID;
GO

請參閱

其他資源

How to: Measure Latency and Validate Connections for Transactional Replication (Replication Transact-SQL Programming)

說明及資訊

取得 SQL Server 2005 協助