sp_dropdistributiondb(Transact-SQL)

적용 대상:SQL ServerAzure SQL Managed Instance

배포 데이터베이스를 삭제합니다. 다른 데이터베이스에서 사용하지 않는 경우 데이터베이스에서 사용하는 물리적 파일을 삭제합니다. 이 저장 프로시저는 모든 데이터베이스의 배포자에서 실행됩니다.

Transact-SQL 구문 표기 규칙

구문

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

인수

[ @database = ] N'database'

삭제할 데이터베이스입니다. @database sysname이며 기본값은 없습니다.

[ @former_ag_secondary = ] former_ag_secondary

이 노드가 이전에 배포 데이터베이스에 대한 가용성 그룹의 일부였는지 여부를 지정합니다. @former_ag_secondary 기본값0int입니다.

반환 코드 값

0 (성공) 또는 1 (실패).

설명

sp_dropdistributiondb는 모든 유형의 복제본(replica)에서 사용됩니다.

이 저장 프로시저는 배포자를 삭제하기 전에 실행 sp_dropdistributor해야 합니다.

sp_dropdistributiondb 또한 배포 데이터베이스에 대한 큐 판독기 에이전트 작업이 있는 경우 제거합니다.

배포를 사용하지 않도록 설정하려면 배포 데이터베이스가 온라인이어야 합니다. 배포 데이터베이스에 대한 데이터베이스 스냅샷 있는 경우 배포를 사용하지 않도록 설정하기 전에 삭제해야 합니다. 데이터베이스 스냅샷 데이터베이스의 읽기 전용 오프라인 복사본이며 복제본(replica)tion 스냅샷 관련이 없습니다. 자세한 내용은 데이터베이스 스냅샷(SQL Server)를 참조하세요.

예제

-- 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'AdventureWorks2022';

-- Disable the publication database.
USE [AdventureWorks2022]
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수 있습니다.