sp_posttracertoken(Transact-SQL)

적용 대상:SQL Server

이 프로시저는 추적 프로그램 토큰을 게시자의 트랜잭션 로그에 게시하고 대기 시간 통계 추적 프로세스를 시작합니다. 정보는 추적 프로그램 토큰이 트랜잭션 로그에 기록될 때, 로그 판독기 에이전트에 의해 선택될 때 및 배포 에이전트 의해 적용될 때 기록됩니다. 이 저장 프로시저는 게시 데이터베이스의 게시자에서 실행됩니다. 자세한 내용은 트랜잭션 복제에 대한 대기 시간 측정 및 커넥트 유효성 검사를 참조하세요.

Transact-SQL 구문 표기 규칙

구문

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

인수

[ @publication = ] 'publication' 대기 시간을 측정할 게시의 이름입니다. 게시는 sysname이며 기본값은 없습니다.

[ @tracer_token_id = ] _tracer_token_id OUTPUT 삽입된 추적 프로그램 토큰의 ID입니다. tracer_token_id 기본값이 NULL인 int이며 OUTPUT 매개 변수입니다. 이 값은 sp_helptracertokens(Transact-SQL)를 먼저 실행하지 않고 sp_helptracertokenhistory(Transact-SQL) 또는 sp_deletetracertokenhistory(Transact-SQL)를 실행하는 데 사용할 수 있습니다.

[ @publisher = ] 'publisher' Microsoft SQL Server 이외 게시자를 지정합니다. 게시자는Sysname이며 기본값은 NULL이며 SQL Server 게시자에 대해 지정해서는 안 됩니다.

반환 코드 값

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

설명

sp_posttracertoken 트랜잭션 복제본(replica) 사용됩니다.

예시

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 실행할 수 있습니다.

참고 항목

트랜잭션 복제에 대한 대기 시간 측정 및 커넥트 유효성 검사