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 |
|
|
|
[!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
sp_dropdistributiondb
[ @database = ] N'database'
[ , [ @former_ag_secondary = ] former_ag_secondary ]
[ ; ]
The database to drop. @database is sysname, with no default.
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
.
0
(success) or 1
(failure).
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).
:::code language="sql" source="../replication/codesnippet/tsql/sp-dropdistributiondb-tr_1.sql":::
Only members of the sysadmin fixed server role can execute sp_dropdistributiondb
.