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), 而且可以是下列其中一個值。

Description
all 推送、提取和匿名訂閱
anonymous 匿名訂用帳戶。
push 發送訂閱。
pull 提取訂用帳戶。
both (預設值) 推送和提取訂閱。

[ @ignore_distributor = ] ignore_distributor

指出是否執行這個預存程式,而不連接到散發者。 @ignore_distributor bit ,預設值為 0 。 此參數可用來卸載訂閱,而不需在散發者端執行清除工作。 如果您必須重新安裝散發者,也很有用。

[ @reserved = ] 保留

保留供未來使用。 @reserved bit ,預設值為 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

權限

只有系統管理員 固定伺服器角色 或db_owner 固定資料庫角色的成員 才能執行 sp_dropmergesubscription