sp_helptracertokens (Transact-SQL)

針對插入發行集以判斷延遲的每個追蹤 Token,各傳回一個資料列。 這個預存程序執行於發行集資料庫的發行者端,或散發資料庫的散發者端。

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

語法

sp_helptracertokens [ @publication = ] 'publication' 
    [ , [ @publisher = ] 'publisher' ] 
    [ , [ @publisher_db = ] 'publisher_db' ]

引數

  • [ @publication= ] 'publication'
    這是插入追蹤 Token 的發行集名稱。 publication 是 sysname,沒有預設值。

  • [ @publisher= ] 'publisher'
    發行者的名稱。 publisher 是 sysname,預設值是 NULL。

    [!附註]

    這個參數只應指定給非 Microsoft SQL Server 發行者。

  • [ @publisher_db= ] 'publisher_db'
    發行集資料庫的名稱。 publisher_db 是 sysname,預設值為 NULL。 如果預存程序執行於發行者端,則會忽略這個參數。

結果集

資料行名稱

資料類型

說明

tracer_id

int

識別追蹤 Token 記錄。

publisher_commit

datetime

在發行集資料庫的發行者端認可 Token 記錄的日期和時間。

傳回碼值

0 (成功) 或 1 (失敗)

備註

sp_helptracertokens 用於異動複寫中。

sp_helptracertokens 用來執行 sp_helptracertokenhistory (Transact-SQL) 時取得追蹤 Token 識別碼。

範例

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

USE [AdventureWorks2012]

-- 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

權限

只有系統管理員 (sysadmin) 固定伺服器角色、發行集資料庫中的 db_owner 固定資料庫角色,或者散發資料庫中的 db_owner 固定資料庫或 replmonitor 角色的成員,才能夠執行 sp_helptracertokenhistory

請參閱

參考

sp_deletetracertokenhistory (Transact-SQL)

概念

針對異動複寫測量延遲及驗證連接