Skip to content

Latest commit

 

History

History
74 lines (51 loc) · 2.86 KB

sp-dropdistributiondb-transact-sql.md

File metadata and controls

74 lines (51 loc) · 2.86 KB
title description author ms.author ms.reviewer ms.date ms.service ms.subservice ms.topic f1_keywords helpviewer_keywords dev_langs
sp_dropdistributiondb (Transact-SQL)
Drops a distribution database and files used by it if they aren't used by another database. This stored procedure runs at the Distributor on any database.
markingmyname
maghan
randolphwest
11/28/2023
sql
replication
reference
sp_dropdistributiondb_TSQL
sp_dropdistributiondb
sp_dropdistributiondb
TSQL

sp_dropdistributiondb (Transact-SQL)

[!INCLUDE SQL Server SQL MI]

Drops a distribution database. Drops the physical files used by the database if they aren't used by another database. This stored procedure is executed at the Distributor on any database.

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

Syntax

sp_dropdistributiondb
    [ @database = ] N'database'
    [ , [ @former_ag_secondary = ] former_ag_secondary ]
[ ; ]

Arguments

[ @database = ] N'database'

The database to drop. @database is sysname, with no default.

[ @former_ag_secondary = ] former_ag_secondary

Specifies whether this node was previously part of an availability group for the distribution database. @former_ag_secondary is int, with a default of 0.

Return code values

0 (success) or 1 (failure).

Remarks

sp_dropdistributiondb is used in all types of replication.

This stored procedure must be executed before dropping the Distributor by executing sp_dropdistributor.

sp_dropdistributiondb also removes a Queue Reader Agent job for the distribution database, if one exists.

To disable distribution, the distribution database must be online. If a database snapshot exists for the distribution database, it must be dropped before disabling distribution. A database snapshot is a read-only offline copy of a database, and isn't related to a replication snapshot. For more information, see Database snapshots (SQL Server).

Examples

:::code language="sql" source="../replication/codesnippet/tsql/sp-dropdistributiondb-tr_1.sql":::

Permissions

Only members of the sysadmin fixed server role can execute sp_dropdistributiondb.

Related content