Udostępnij za pośrednictwem


Jak Usuwanie subskrypcji ściąganej (Programowanie replikacji Transact-SQL)

Można usunąć subskrypcji ściąganej programowo za pomocą procedur przechowywanych replikacja.Procedury przechowywane, używany będzie zależeć od typu publikacja, do której należy subskrypcja.

Aby usunąć subskrypcja wciągana migawka lub transakcyjnych publikacja

  1. Subskrybent na baza danych subskrypcja, wykonać sp_droppullsubscription (języka Transact-SQL).Określ publikacja @, programu publisher @, i @ publisher_db.

  2. Wydawca na baza danych publikacja, wykonanie sp_dropsubscription (języka Transact-SQL).Określ publikacja @ i @ subskrybent.Określ wartość wszystkich dla @ artykuł.(Opcjonalnie) Jeśli dystrybutor, nie są dostępne, należy określić wartość 1 dla @ ignore_distributor do usunięcia subskrypcja bez usuwania obiektów pokrewnych u dystrybutora.

Aby usunąć subskrypcja wciągana do publikacja korespondencji seryjnej

  1. Subskrybent na baza danych subskrypcja, wykonać sp_dropmergepullsubscription (języka Transact-SQL).Określ publikacja @, programu publisher @, i @ publisher_db.

  2. Wydawca na baza danych publikacja, wykonanie sp_dropmergesubscription (języka Transact-SQL).Określ publikacja @, @ subskrybent, i @ subscriber_db.Określ wartość ściągać dla @ subscription_type.(Opcjonalnie) Jeśli dystrybutor, nie są dostępne, należy określić wartość 1 dla @ ignore_distributor do usunięcia subskrypcja bez usuwania obiektów pokrewnych u dystrybutora.

Przykład

W następującym przykładzie usunięto subskrypcja wciągana do publikacja transakcyjnych.Pierwsza partia jest wykonywany przez subskrybenta i drugi jest wykonywana na Wydawca.

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

USE [AdventureWorks2008R2Replica]
EXEC sp_droppullsubscription 
  @publisher = @publisher, 
  @publisher_db = @publicationDB, 
  @publication = @publication;
GO
-- 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 transactional publication.
DECLARE @publication AS sysname;
DECLARE @subscriber AS sysname;
SET @publication = N'AdvWorksProductTran';
SET @subscriber = $(SubServer);

USE [AdventureWorks2008R2;]
EXEC sp_dropsubscription 
  @publication = @publication, 
  @article = N'all',
  @subscriber = @subscriber;
GO

W następującym przykładzie usunięto subskrypcja wciągana do publikacja korespondencji seryjnej.Pierwsza partia jest wykonywany przez subskrybenta i drugi jest wykonywana na Wydawca.

-- 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 Subscriber to remove 
-- a merge pull subscription.
DECLARE @publication AS sysname;
DECLARE @publisher AS sysname;
DECLARE @publication_db AS sysname;
SET @publication = N'AdvWorksSalesOrdersMerge';
SET @publisher = $(PubServer);
SET @publication_db = N'AdventureWorks2008R2';

USE [AdventureWorks2008R2Replica]
EXEC sp_dropmergepullsubscription 
  @publisher = @publisher, 
  @publisher_db = @publication_db, 
  @publication = @publication;
GO
-- 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'AdventureWorks2008R2Replica';

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