| title | sp_change_log_shipping_secondary_database (Transact-SQL) | ||
|---|---|---|---|
| description | sp_change_log_shipping_secondary_database changes secondary database settings. | ||
| author | MashaMSFT | ||
| ms.author | mathoma | ||
| ms.reviewer | randolphwest | ||
| ms.date | 06/23/2025 | ||
| ms.service | sql | ||
| ms.subservice | system-objects | ||
| ms.topic | reference | ||
| f1_keywords |
|
||
| helpviewer_keywords |
|
||
| dev_langs |
|
[!INCLUDE SQL Server]
Changes secondary database settings.
:::image type="icon" source="../../includes/media/topic-link-icon.svg" border="false"::: Transact-SQL syntax conventions
sp_change_log_shipping_secondary_database
[ @secondary_database = ] N'secondary_database'
[ , [ @restore_delay = ] restore_delay ]
[ , [ @restore_all = ] restore_all ]
[ , [ @restore_mode = ] restore_mode ]
[ , [ @disconnect_users = ] disconnect_users ]
[ , [ @block_size = ] block_size ]
[ , [ @buffer_count = ] buffer_count ]
[ , [ @max_transfer_size = ] max_transfer_size ]
[ , [ @restore_threshold = ] restore_threshold ]
[ , [ @threshold_alert = ] threshold_alert ]
[ , [ @threshold_alert_enabled = ] threshold_alert_enabled ]
[ , [ @history_retention_period = ] history_retention_period ]
[ , [ @ignoreremotemonitor = ] ignoreremotemonitor ]
[ ; ]
The database name on the secondary server. @secondary_database is sysname, with no default.
The amount of time, in minutes, that the secondary server waits before restoring a given backup file. @restore_delay is int, with a default of 0, and can't be NULL.
If set to 1, the secondary server restores all available transaction log backups when the restore job runs. Otherwise, it stops after one file is restored. @restore_all is bit, and can't be NULL.
The restore mode for the secondary database. @restore_mode is bit, and can't be NULL.
0= restore log withNORECOVERY.1= restore log withSTANDBY.
If set to 1, users are disconnected from the secondary database when a restore operation is performed. @disconnect_users is bit, with a default of 0, and can't be NULL.
The size, in bytes, that is used as the block size for the backup device. @block_size is int, with a default of -1.
The total number of buffers used by the backup or restore operation. @buffer_count is int, with a default of -1.
The size, in bytes, of the maximum input or output request that is issued by [!INCLUDE ssNoVersion] to the backup device. @max_transfer_size is int, with a default of NULL.
The number of minutes allowed to elapse between restore operations before an alert is generated. @restore_threshold is int, and can't be NULL.
The alert to be raised when the restore threshold is exceeded. @threshold_alert is int, with a default of 14421.
Specifies whether an alert is raised when @restore_threshold is exceeded.
1= enabled0= disabled.
@threshold_alert_enabled is bit, and can't be NULL.
The length of time in minutes in which the history is retained. @history_retention_period is int, with a default of 1440.
[!INCLUDE ssinternalonly-md]
0 (success) or 1 (failure).
None.
sp_change_log_shipping_secondary_database must be run from the master database on the secondary server. This stored procedure performs the following steps:
-
Changes the settings in the
log_shipping_secondary_databaserecords as necessary. -
Changes the local monitor record in
log_shipping_monitor_secondaryon the secondary server using supplied arguments, if necessary.
Only members of the sysadmin fixed server role can run this procedure.
This example illustrates using sp_change_log_shipping_secondary_database to update secondary database parameters for the database LogShipAdventureWorks.
EXECUTE master.dbo.sp_change_log_shipping_secondary_database
@secondary_database = 'LogShipAdventureWorks',
@restore_delay = 0,
@restore_all = 1,
@restore_mode = 0,
@disconnect_users = 0,
@threshold_alert = 14420,
@threshold_alert_enabled = 1,
@history_retention_period = 14420;