sp_cleanup_log_shipping_history (Transact-SQL)sp_cleanup_log_shipping_history (Transact-SQL)

适用对象: 是SQL Server 否Azure SQL 数据库 否Azure Synapse Analytics (SQL DW) 否并行数据仓库APPLIES TO: yesSQL Server noAzure SQL Database noAzure Synapse Analytics (SQL DW) noParallel Data Warehouse

此存储过程将根据保持期,清理本地和监视服务器上的历史记录。This stored procedure cleans up history locally and on the monitor server based on retention period.

主题链接图标 Transact-SQL 语法约定Topic link icon Transact-SQL Syntax Conventions

语法Syntax

  
sp_cleanup_log_shipping_history  
[ @agent_id = ] 'agent_id',  
[ @agent_type = ] 'agent_type'  

参数Arguments

[ @agent_id = ] 'agent_id',用于备份的主 ID 或者用于复制或还原的辅助 ID。[ @agent_id = ] 'agent_id', The primary ID for backup or the secondary ID for copy or restore. agent_iduniqueidentifier ,且不能为 NULL。agent_id is uniqueidentifier and cannot be NULL.

[ @agent_type = ] 'agent_type'日志传送作业的类型。[ @agent_type = ] 'agent_type' The type of log shipping job. 0 = 备份,1 = 复制,2 = 还原。0 = Backup, 1 = Copy, 2 = Restore. agent_typetinyint ,且不能为 NULL。agent_type is tinyint and cannot be NULL.

返回代码值Return Code Values

0(成功)或 1(失败)0 (success) or 1 (failure)

结果集Result Sets

无。None.

备注Remarks

必须从任何日志传送服务器上的master数据库运行sp_cleanup_log_shipping_historysp_cleanup_log_shipping_history must be run from the master database on any log shipping server. 此存储过程将根据历史记录保持期,清理log_shipping_monitor_history_detaillog_shipping_monitor_error_detail的本地和远程副本。This stored procedure cleans up local and remote copies of log_shipping_monitor_history_detail and log_shipping_monitor_error_detail based on history retention period.

权限Permissions

只有sysadmin固定服务器角色的成员才能运行此过程。Only members of the sysadmin fixed server role can run this procedure.

另请参阅See Also

关于日志传送 (SQL Server) About Log Shipping (SQL Server)
系统存储过程 (Transact-SQL)System Stored Procedures (Transact-SQL)