sp_deletetracertokenhistory (Transact-SQL)

APPLIES TO: yesSQL Server yesAzure SQL Database (Managed Instance only) noAzure SQL Data Warehouse noParallel Data Warehouse

Removes tracer token records from the MStracer_tokens (Transact-SQL) and MStracer_history (Transact-SQL) system tables. This stored procedure is executed at the Publisher on the publication database or at the Distributor on the distribution database.

Topic link icon Transact-SQL Syntax Conventions

Syntax

sp_deletetracertokenhistory [ @publication = ] 'publication'
    [ , [ @tracer_id = ] tracer_id ]
    [ , [ @cutoff_date = ] cutoff_date ]
    [ , [ @publisher = ] 'publisher' ]
    [ , [ @publisher_db = ] 'publisher_db' ]

Arguments

@publication= 'publication'
Is the name of the publication in which the tracer token was inserted. The data type is sysname. This parameter is required.

[ @tracer_id= ] tracer_id
Is the ID of the tracer token to delete. The data type is int. The default value is null. If null, all tracer tokens belonging to the publication are deleted.

[ @cutoff_date= ] cutoff_date
Tracer tokens inserted into the publication before this date are deleted. The data type is datetime. The default value is null.

[ @publisher= ] 'publisher'
Is the name of the Publisher. The data type is sysname. The default value is null.

Note

This parameter should only be specified for non- MicrosoftSQL Server Publishers or when executing the stored procedure from distributor.

[ @publisher_db= ] 'publisher_db'
Is the name of the publication database. The data type is sysname. The default value is NULL. This parameter is ignored if the stored procedure is executed at the Publisher.

Note

This parameter should be specified when executing the stored procedure from distributor.

Return Code Values

0 (success) or 1 (failure)

Remarks

sp_deletetracertokenhistory is used in transactional replication.

An error occurs if you specify both parameters tracer_id and cutoff_date.

If you do not execute sp_deletetracertokenhistory to delete tracer token metadata, the information will be deleted when the regularly scheduled history cleanup occurs.

Tracer token IDs can be determined by executing sp_helptracertokens (Transact-SQL) or by querying the MStracer_tokens (Transact-SQL) system table.

Permissions

Only the following personnel have the authority to execute sp_deletetracertokenhistory:

  • Members of the replmonitor roles, in the distribution database
  • Members of the sysadmin fixed server role.
  • Members of the db_owner fixed database role, in the publication database.
  • The db_owner of the fixed database.

See Also

Measure Latency and Validate Connections for Transactional Replication

sp_helptracertokenhistory (Transact-SQL)