| title | sp_delete_log_shipping_primary_database (Transact-SQL) | ||
|---|---|---|---|
| description | Removes log shipping of primary database including backup job, and local and remote history. | ||
| 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]
This stored procedure removes log shipping of primary database including backup job, local and remote history. Only use this stored procedure after you remove the secondary databases using sp_delete_log_shipping_primary_secondary.
:::image type="icon" source="../../includes/media/topic-link-icon.svg" border="false"::: Transact-SQL syntax conventions
sp_delete_log_shipping_primary_database
[ @database = ] N'database'
[ , [ @ignoreremotemonitor = ] ignoreremotemonitor ]
[ ; ]
The name of the log shipping primary database. @database is sysname, with no default, and can't be NULL.
[!INCLUDE ssinternalonly-md]
0 (success) or 1 (failure).
None.
sp_delete_log_shipping_primary_database must be run from the master database on the primary server. This stored procedure performs the following steps:
-
Deletes the backup job for the specified primary database.
-
Removes the local monitor record in
log_shipping_monitor_primaryon the primary server. -
Removes corresponding entries in
log_shipping_monitor_history_detailandlog_shipping_monitor_error_detail. -
If the monitor server is different from the primary server, it removes the monitor record in
log_shipping_monitor_primaryon the monitor server. -
Removes corresponding entries in
log_shipping_monitor_history_detailandlog_shipping_monitor_error_detailon the monitor server. -
Removes the entry in
log_shipping_primary_databasesfor this primary database. -
Calls
sp_delete_log_shipping_alert_jobon the monitor server.
Only members of the sysadmin fixed server role can run this procedure.
This example illustrates using sp_delete_log_shipping_primary_database to delete the primary database [!INCLUDE sssampledbobject-md].
EXECUTE master.dbo.sp_delete_log_shipping_primary_database
@database = N'AdventureWorks2022';
GO