sp_dropmergesubscription (Transact-SQL)

適用対象:SQL Server

マージ パブリケーションのサブスクリプションおよびこれと関連するマージ エージェントを削除します。 このストアド プロシージャは、パブリッシャー側のパブリケーション データベースで実行されます。

Transact-SQL 構文表記規則

構文

sp_dropmergesubscription
    [ [ @publication = ] N'publication' ]
    [ , [ @subscriber = ] N'subscriber' ]
    [ , [ @subscriber_db = ] N'subscriber_db' ]
    [ , [ @subscription_type = ] N'subscription_type' ]
    [ , [ @ignore_distributor = ] ignore_distributor ]
    [ , [ @reserved = ] reserved ]
[ ; ]

引数

[ @publication = ] N'publication'

パブリケーション名です。 @publicationは sysname で、既定値は NULL. パブリケーションは既に存在し、識別子の規則 に準拠している必要があります。

[ @subscriber = ] N'subscriber'

サブスクライバーの名前。 @subscriberは sysname で、既定値は NULL.

[ @subscriber_db = ] N'subscriber_db'

サブスクリプション データベースの名前。 @subscriber_dbは sysname で、既定値は NULL.

[ @subscription_type = ] N'subscription_type'

サブスクリプションの種類。 @subscription_typeは nvarchar(15)で、これらの値のいずれかを指定できます。

説明
all プッシュ、プル、匿名のサブスクリプション
anonymous 匿名サブスクリプションです。
push プッシュ サブスクリプション。
pull プル サブスクリプションです。
both (既定) プッシュ サブスクリプションおよびプル サブスクリプションです。

[ @ignore_distributor = ] ignore_distributor

ディストリビューターに接続せずにこのストアド プロシージャを実行するかどうかを示します。 @ignore_distributorはビットで、既定値は 0. このパラメーターを使用すると、ディストリビューターでクリーンアップ タスクを実行せずにサブスクリプションを削除できます。 ディストリビューターを再インストールする必要がある場合にも便利です。

[ @reserved = ] 予約済み

将来利用するために予約されています。 @reservedはビットで、既定値は 0.

リターン コードの値

0 (成功) または 1 (失敗)。

解説

sp_dropmergesubscription はマージ レプリケーションで使用されます。

-- 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".

-- This batch is executed at the Publisher to remove 
-- a pull or push subscription to a merge publication.
DECLARE @publication AS sysname;
DECLARE @subscriber AS sysname;
DECLARE @subscriptionDB AS sysname;
SET @publication = N'AdvWorksSalesOrdersMerge';
SET @subscriber = $(SubServer);
SET @subscriptionDB = N'AdventureWorks2022Replica';

USE [AdventureWorks2022]
EXEC sp_dropmergesubscription 
  @publication = @publication, 
  @subscriber = @subscriber, 
  @subscriber_db = @subscriptionDB;
GO

アクセス許可

sysadmin 固定サーバー ロールまたは固定データベース ロールdb_ownerのメンバーのみが実行sp_dropmergesubscriptionできます。