sp_droppullsubscription (Transact-SQL)

適用対象: SQL ServerAzure SQL Managed Instance

サブスクライバーの現在のデータベースにあるサブスクリプションを削除します。 このストアド プロシージャは、サブスクライバー側でプル サブスクリプション データベースについて実行されます。

Transact-SQL 構文表記規則

構文

sp_droppullsubscription
    [ @publisher = ] N'publisher'
    [ , [ @publisher_db = ] N'publisher_db' ]
    , [ @publication = ] N'publication'
    [ , [ @reserved = ] reserved ]
    [ , [ @from_backup = ] from_backup ]
[ ; ]

引数

[ @publisher = ] N'publisher'

リモート サーバー名。 @publisherは sysname で、既定値はありません。 その場合 all、サブスクリプションはすべてのパブリッシャーで削除されます。

[ @publisher_db = ] N'publisher_db'

パブリッシャー データベースの名前。 @publisher_dbは sysname で、既定値は NULL. all は、すべてのパブリッシャー データベースを意味します。

[ @publication = ] N'publication'

パブリケーション名です。 @publicationは sysname で、既定値はありません。 その場合 all、サブスクリプションはすべてのパブリケーションにドロップされます。

[ @reserved = ] 予約済み

単に情報を示すためだけに特定されます。 サポートされていません。 将来の互換性は保証されません。

[ @from_backup = ] from_backup

単に情報を示すためだけに特定されます。 サポートされていません。 将来の互換性は保証されません。

リターン コードの値

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

解説

sp_droppullsubscriptionは、スナップショット レプリケーションとトランザクション レプリケーションで使用されます。

sp_droppullsubscriptionは、MSreplication_subscriptions (Transact-SQL) テーブル内の対応する行とサブスクライバーの対応するディストリビューター エージェントを削除します。 MSreplication_subscriptions (Transact-SQL)行が残っていない場合は、テーブルが削除されます。

-- 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 is the batch executed at the Subscriber to drop 
-- a pull subscription to a transactional publication.
DECLARE @publication AS sysname;
DECLARE @publisher AS sysname;
DECLARE @publicationDB     AS sysname;
SET @publication = N'AdvWorksProductTran';
SET @publisher = $(PubServer);
SET @publicationDB = N'AdventureWorks2022';

USE [AdventureWorks2022Replica]
EXEC sp_droppullsubscription 
  @publisher = @publisher, 
  @publisher_db = @publicationDB, 
  @publication = @publication;
GO

アクセス許可

sysadmin 固定サーバー ロールのメンバーまたはプル サブスクリプションを作成したユーザーのみが実行sp_droppullsubscriptionできます。 固定データベース ロールdb_ownerは、プル サブスクリプションを作成したユーザーがこのロールに属している場合にのみ実行sp_droppullsubscriptionできます。