sp_droppullsubscription (Transact-SQL)

在訂閱者的目前資料庫卸除訂閱。 這個預存程序執行於提取訂閱資料庫的訂閱者端。

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

語法

sp_droppullsubscription [ @publisher= ] 'publisher' 
        , [ @publisher_db= ] 'publisher_db' 
        , [ @publication= ] 'publication'
    [ , [ @reserved= ] reserved ]

引數

  • [ @publisher= ] 'publisher'
    這是遠端伺服器的名稱。 publisher 是 sysname,沒有預設值。 如果是 all,就會在所有發行者端卸除訂閱。

  • [ @publisher_db= ] 'publisher_db'
    這是發行者資料庫的名稱。 publisher_db 是 sysname,沒有預設值。 all 代表所有發行者資料庫。

  • [ @publication= ] 'publication'
    這是發行集名稱。 publication 是 sysname,沒有預設值。 如果是 all,就會卸除對所有發行集的訂閱。

  • [ @reserved= ] reserved
    僅供參考之用。不支援。我們無法保證未來的相容性。

傳回碼值

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

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

權限

只有系統管理員 (sysadmin) 固定伺服器角色的成員,或建立提取訂閱的使用者,才能夠執行 sp_droppullsubscription。 只有在建立提取訂閱的使用者屬於 db_owner 固定資料庫角色時,這個角色才能夠執行 sp_droppullsubscription

請參閱

參考

sp_addpullsubscription (Transact-SQL)

sp_change_subscription_properties (Transact-SQL)

sp_helppullsubscription (Transact-SQL)

sp_dropsubscription (Transact-SQL)

概念

刪除提取訂閱