Skip to content

Latest commit

 

History

History
71 lines (50 loc) · 2.12 KB

sp-cleanup-log-shipping-history-transact-sql.md

File metadata and controls

71 lines (50 loc) · 2.12 KB
title description author ms.author ms.reviewer ms.date ms.service ms.subservice ms.topic f1_keywords helpviewer_keywords dev_langs
sp_cleanup_log_shipping_history (Transact-SQL)
sp_cleanup_log_shipping_history cleans up history locally, and on the monitor server, based on retention period.
markingmyname
maghan
randolphwest
07/05/2024
sql
system-objects
reference
sp_cleanup_log_shipping_history_TSQL
sp_cleanup_log_shipping_history
sp_cleanup_log_shipping_history
TSQL

sp_cleanup_log_shipping_history (Transact-SQL)

[!INCLUDE SQL Server]

This stored procedure cleans up history locally, and on the monitor server, based on retention period.

:::image type="icon" source="../../includes/media/topic-link-icon.svg" border="false"::: Transact-SQL syntax conventions

Syntax

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

Arguments

[ @agent_id = ] 'agent_id'

The primary ID for backup or the secondary ID for copy or restore. @agent_id is uniqueidentifier, with no default, and can't be NULL.

[ @agent_type = ] agent_type

The type of log shipping job. @agent_type is tinyint, with no default, and must be one of these values:

Value Description
0 Backup
1 Copy
2 Restore

Return code values

0 (success) or 1 (failure).

Result set

None.

Remarks

sp_cleanup_log_shipping_history must be run from the master database on any log shipping server. 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

Only members of the sysadmin fixed server role can run this procedure.

Related content