sp_helptracertokens (Transact-SQL)

为每个插入到发布以确定滞后时间的跟踪标记分别返回一行。 此存储过程用于在发布服务器上对发布数据库执行,或在分发服务器上对分发数据库执行。

主题链接图标 Transact-SQL 语法约定

语法

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

参数

  • [ @publication= ] 'publication'
    插入了跟踪令牌的发布的名称。 publication 的数据类型为 sysname,无默认值。

  • [ @publisher= ] 'publisher'
    发布服务器的名称。 publisher 的数据类型为 sysname,默认值为 NULL。

    注意注意

    应只为非 Microsoft SQL Server 发布服务器指定此参数。

  • [ @publisher_db= ] 'publisher_db'
    发布数据库的名称。 publisher_db 的数据类型为 sysname,默认值为 NULL。 如果在发布服务器上执行该存储过程,将忽略此参数。

结果集

列名

数据类型

说明

tracer_id

int

标识跟踪令牌记录。

publisher_commit

datetime

在发布服务器的发布数据库中提交标记记录的日期和时间。

返回代码值

0(成功)或 1(失败)

注释

sp_helptracertokens 用于事务复制。

在执行 sp_helptracertokenhistory (Transact-SQL)sp_helptracertokens 用于获取跟踪标记 ID。

示例

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)

概念

为事务复制测量滞后时间和验证连接