sp_posttracertoken(Transact-SQL)

적용 대상: SQL Server

이 프로시저는 추적 프로그램 토큰을 게시자의 트랜잭션 로그에 게시하고 대기 시간 통계 추적 프로세스를 시작합니다.

정보가 기록됩니다.

  • 추적 프로그램 토큰이 트랜잭션 로그에 기록되면 이고,
  • 로그 판독기 에이전트가 이 에이전트를 선택하면 이고, 그리고
  • 배포 에이전트 적용됩니다.

이 저장 프로시저는 게시 데이터베이스의 게시자에서 실행됩니다. 자세한 내용은 트랜잭션 복제에 대한 대기 시간 측정 및 연결 유효성 검사를 참조하세요.

Transact-SQL 구문 표기 규칙

구문

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

인수

[ @publication = ] N'publication'

대기 시간을 측정할 게시의 이름입니다. @publication 기본값이 없는 sysname입니다.

[ @tracer_token_id = ] tracer_token_id OUTPUT

삽입된 추적 프로그램 토큰의 ID입니다. @tracer_token_id int 형식의 OUTPUT 매개 변수입니다. 이 값은 먼저 sp_helptracertokens 실행하지 않고 sp_helptracertokenhistory 또는 sp_deletetracertokenhistory 실행하는 데 사용할 수 있습니다.

[ @publisher = ] N'publisher'

SQL Server 이외 게시자를 지정합니다. @publisher sysname이며 기본값은 .입니다NULL. 이 매개 변수는 SQL Server 게시자에 대해 지정해서는 안 됩니다.

반환 코드 값

0(성공) 또는 1(실패).

설명

sp_posttracertoken 는 트랜잭션 복제에 사용됩니다.

예제

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

USE [AdventureWorks2022]

-- 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 고정 데이터베이스 역할의 멤버만 실행할 sp_posttracertoken수 있습니다.