Skip to content

Latest commit

 

History

History
89 lines (59 loc) · 3.04 KB

sp-delete-log-shipping-primary-database-transact-sql.md

File metadata and controls

89 lines (59 loc) · 3.04 KB
title description author ms.author ms.reviewer ms.date ms.service ms.subservice ms.topic f1_keywords helpviewer_keywords dev_langs
sp_delete_log_shipping_primary_database (Transact-SQL)
Removes log shipping of primary database including backup job, and local and remote history.
MashaMSFT
mathoma
randolphwest
01/23/2024
sql
system-objects
reference
sp_delete_log_shipping_primary_database
sp_delete_log_shipping_primary_database_TSQL
sp_delete_log_shipping_primary_database
TSQL

sp_delete_log_shipping_primary_database (Transact-SQL)

[!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

Syntax

sp_delete_log_shipping_primary_database
    [ @database = ] N'database'
    [ , [ @ignoreremotemonitor = ] ignoreremotemonitor ]
[ ; ]

Arguments

[ @database = ] N'database'

The name of the log shipping primary database. @database is sysname, with no default, and can't be NULL.

[ @ignoreremotemonitor = ] ignoreremotemonitor

[!INCLUDE ssinternalonly-md]

Return code values

0 (success) or 1 (failure).

Result set

None.

Remarks

sp_delete_log_shipping_primary_database must be run from the master database on the primary server. This stored procedure performs the following steps:

  1. Deletes the backup job for the specified primary database.

  2. Removes the local monitor record in log_shipping_monitor_primary on the primary server.

  3. Removes corresponding entries in log_shipping_monitor_history_detail and log_shipping_monitor_error_detail.

  4. If the monitor server is different from the primary server, it removes the monitor record in log_shipping_monitor_primary on the monitor server.

  5. Removes corresponding entries in log_shipping_monitor_history_detail and log_shipping_monitor_error_detail on the monitor server.

  6. Removes the entry in log_shipping_primary_databases for this primary database.

  7. Calls sp_delete_log_shipping_alert_job on the monitor server.

Permissions

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

Examples

This example illustrates using sp_delete_log_shipping_primary_database to delete the primary database [!INCLUDE sssampledbobject-md].

EXEC master.dbo.sp_delete_log_shipping_primary_database
    @database = N'AdventureWorks2022';
GO

Related content