sp_dropmergearticle (Transact-SQL)

從合併式發行集中移除發行項。 這個預存程序執行於發行集資料庫的發行者端。

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

語法

sp_dropmergearticle [ @publication= ] 'publication'
        , [ @article= ] 'article' 
    [ , [ @ignore_distributor= ] ignore_distributor 
    [ , [ @reserved= ] reserved 
    [ , [ @force_invalidate_snapshot= ] force_invalidate_snapshot ]
    [ , [ @force_reinit_subscription = ] force_reinit_subscription ]
    [ , [ @ignore_merge_metadata = ] ignore_merge_metadata ]

引數

  • [@publication=] 'publication'
    這是要卸除發行項的發行集名稱。publication 是 sysname,沒有預設值。

  • [@article=] 'article'
    這是給定發行集所要卸除的發行項名稱。article 是 sysname,沒有預設值。 如果是 all,便會移除指定合併式發行集中所有現有的發行項。 即使 article 是 all,您仍必須從發行項中個別卸除發行集。

  • [@ignore_distributor=] ignore_distributor
    指出是否在未連接到散發者的情況之下,執行這個預存程序。ignore_distributor 是 bit,預設值是 0

  • [@reserved=] reserved
    保留供日後使用。reserved 是 nvarchar(20),預設值是 NULL。

  • [@force_invalidate_snapshot = ] force_invalidate_snapshot
    啟用或停用使快照集失效的能力。force_invalidate_snapshot 是 bit,預設值是 0

    0 指定合併發行項的變更不會使快照集失效。

    1 表示合併發行項的變更可能使快照集失效,若是如此,1 值會提供將出現之新快照集的權限。

  • [@force_reinit_subscription = ] force_reinit_subscription
    認可卸除發行項需要重新初始化現有的訂閱。force_reinit_subscription 是 bit,預設值是 0

    0 指定卸除發行項並不會使訂閱重新初始化。

    1 表示卸除發行項會使現有的訂閱重新初始化,且會提供將發生之訂閱重新初始化的權限。

  • [@ignore_merge_metadata= ] ignore_merge_metadata
    僅供內部使用。

傳回碼值

0 (成功) 或 1 (失敗)

備註

sp_dropmergearticle 用於合併式複寫中。 如需有關卸除發行項的詳細資訊,請參閱<在現有發行集中加入和卸除發行項>。

執行 sp_dropmergearticle 來卸除發行集中的發行項,並不會從發行集資料庫中移除物件,也不會從訂閱資料庫中移除對應的物件。 必要的話,請利用 DROP <object> 來手動移除這些物件。

範例

DECLARE @publication AS sysname;
DECLARE @table1 AS sysname;
DECLARE @table2 AS sysname;
DECLARE @table3 AS sysname;
DECLARE @salesschema AS sysname;
DECLARE @hrschema AS sysname;
DECLARE @filterclause AS nvarchar(1000);
SET @publication = N'AdvWorksSalesOrdersMerge'; 
SET @table1 = N'Employee'; 
SET @table2 = N'SalesOrderHeader'; 
SET @table3 = N'SalesOrderDetail'; 
SET @salesschema = N'Sales';
SET @hrschema = N'HumanResources';
SET @filterclause = N'Employee.LoginID = HOST_NAME()';

-- Drop the merge join filter between SalesOrderHeader and SalesOrderDetail.
EXEC sp_dropmergefilter 
  @publication = @publication, 
  @article = @table3, 
  @filtername = N'SalesOrderDetail_SalesOrderHeader', 
  @force_invalidate_snapshot = 1, 
  @force_reinit_subscription = 1;

-- Drops the merge join filter between Employee and SalesOrderHeader.
EXEC sp_dropmergefilter 
  @publication = @publication, 
  @article = @table2, 
  @filtername = N'SalesOrderHeader_Employee', 
  @force_invalidate_snapshot = 1, 
  @force_reinit_subscription = 1;

-- Drops the article for the SalesOrderDetail table.
EXEC sp_dropmergearticle 
  @publication = @publication, 
  @article = @table3,
  @force_invalidate_snapshot = 1, 
  @force_reinit_subscription = 1;

-- Drops the article for the SalesOrderHeader table.
EXEC sp_dropmergearticle 
  @publication = @publication, 
  @article = @table2, 
  @force_invalidate_snapshot = 1, 
  @force_reinit_subscription = 1;

-- Drops the article for the Employee table.
EXEC sp_dropmergearticle 
  @publication = @publication, 
  @article = @table1,
  @force_invalidate_snapshot = 1, 
  @force_reinit_subscription = 1;
GO

DECLARE @publication AS sysname;
DECLARE @article1 AS sysname;
DECLARE @article2 AS sysname;
SET @publication = N'AdvWorksSalesOrdersMerge';
SET @article1 = N'SalesOrderDetail'; 
SET @article2 = N'SalesOrderHeader'; 

-- Remove articles from a merge publication.
USE [AdventureWorks2008R2]
EXEC sp_dropmergearticle 
  @publication = @publication, 
  @article = @article1,
  @force_invalidate_snapshot = 1;
EXEC sp_dropmergearticle 
  @publication = @publication, 
  @article = @article2,
  @force_invalidate_snapshot = 1;
GO

權限

只有系統管理員 (sysadmin) 固定伺服器角色或 db_owner 固定資料庫角色的成員,才能夠執行 sp_dropmergearticle