| title | sp_change_log_shipping_secondary_primary (Transact-SQL) | ||
|---|---|---|---|
| description | Changes secondary database settings. | ||
| author | MashaMSFT | ||
| ms.author | mathoma | ||
| ms.reviewer | randolphwest | ||
| ms.date | 10/22/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_primary
[ @primary_server = ] 'primary_server' ,
[ @primary_database = ] 'primary_database' ,
[ , [ @backup_source_directory = ] N'backup_source_directory' ]
[ , [ @backup_destination_directory = ] N'backup_destination_directory' ]
[ , [ @file_retention_period = ] file_retention_period ]
[ , [ @monitor_server_security_mode = ] monitor_server_security_mode ]
[ , [ @monitor_server_login = ] 'monitor_server_login' ]
[ , [ @monitor_server_password = ] 'monitor_server_password' ]
[ , [ @monitor_connection_options = ] '<key_value_pairs>;[...]' ]
[ ; ]
The name of the primary instance of the [!INCLUDE ssDEnoversion] in the log shipping configuration. @primary_server is sysname and can't be NULL.
The name of the database on the primary server. @primary_database is sysname, with no default.
The directory where transaction log backup files from the primary server are stored. @backup_source_directory is nvarchar(500) and can't be NULL.
The directory on the secondary server where backup files are copied to. @backup_destination_directory is nvarchar(500) and can't be NULL.
The length of time in minutes in which the backup files are retained. @file_retention_period is int, with a default of NULL. A value of 14420 is used if none is specified.
The security mode used to connect to the monitor server.
1: Windows Authentication;0: [!INCLUDE ssNoVersion] Authentication.
@monitor_server_security_mode is bit and defaults to NULL.
The username of the account used to access the monitor server.
The password of the account used to access the monitor server.
Applies to: [!INCLUDE sssql25-md] and later versions
Specifies more connectivity options for the linked server connection when utilizing a remote monitor, in the form of key value pairs. @monitor_connection_options is nvarchar(4000) and has the default of NULL.
The following table lists the available connectivity options:
| Key | Value |
|---|---|
Encrypt |
strict, mandatory, optional, true, false |
TrustServerCertificate |
true, false, yes, no |
ServerCertificate |
Path on the filesystem to the server certificate. This has a maximum length of 260 characters. |
HostNameInCertificate |
Hostname override for the certificate. This has a maximum length of 255 characters. |
0 (success) or 1 (failure).
None.
sp_change_log_shipping_secondary_primary must be run from the master database on the secondary server. This stored procedure does the following actions:
-
Changes settings in
log_shipping_secondaryas necessary. -
If the monitor server is different from the secondary server, changes monitor record in
log_shipping_monitor_secondaryon the monitor server using supplied arguments, if necessary.
Only members of the sysadmin fixed server role can run this procedure.