sp_dropdistributiondb (Transact-SQL)

卸除散發資料庫。如果資料庫所用的實體檔案沒有另一個資料庫在使用,便卸除這些實體檔案。這個預存程序執行於任何資料庫中的散發者端。

主題連結圖示Transact-SQL 語法慣例

語法

sp_dropdistributiondb [ @database= ] 'database'

引數

  • [@database=] 'database'
    這是要卸除的資料庫。database 是 sysname,沒有預設值。

傳回碼值

0 (成功) 或 1 (失敗)

備註

sp_dropdistributiondb 用於所有類型的複寫中。

您必須先執行這個預存程序,然後才能執行 sp_dropdistributor 來卸除散發者。

如果散發資料庫的佇列讀取器代理程式作業存在的話,sp_dropdistributiondb 也會移除這項作業。

若要停用散發,散發資料庫必須在線上。如果散發資料庫的資料庫快照集存在,您必須先卸除它,才能停用散發。資料庫快照集是資料庫的唯讀離線複本,與複寫快照集無關。如需詳細資訊,請參閱<資料庫快照集>。

範例

-- This script uses sqlcmd scripting variables. They are in the form
-- $(MyVariable). For information about how to use scripting variables  
-- on the command line and in SQL Server Management Studio, see the 
-- "Executing Replication Scripts" section in the topic
-- "Programming Replication Using System Stored Procedures".

-- Disable publishing and distribution.
DECLARE @distributionDB AS sysname;
DECLARE @publisher AS sysname;
DECLARE @publicationDB as sysname;
SET @distributionDB = N'distribution';
SET @publisher = $(DistPubServer);
SET @publicationDB = N'AdventureWorks2008R2';

-- Disable the publication database.
USE [AdventureWorks2008R2]
EXEC sp_removedbreplication @publicationDB;

-- Remove the registration of the local Publisher at the Distributor.
USE master
EXEC sp_dropdistpublisher @publisher;

-- Delete the distribution database.
EXEC sp_dropdistributiondb @distributionDB;

-- Remove the local server as a Distributor.
EXEC sp_dropdistributor;
GO

權限

只有系統管理員 (sysadmin) 固定伺服器角色的成員,才能夠執行 sp_dropdistributiondb