Share via


Çekme abonelik silmek

Bu konuda bir çekme Abonelik silmek açıklar SQL Server 2012kullanarak SQL Server Management Studio, Transact-SQL, ya da Çoğaltma Yönetimi Nesneleri'ni (rmo).

Bu Konuda

  • Çekme abonelik silmek için kullanma:

    SQL Server Management Studio

    Transact-SQL

    Çoğaltma Yönetimi Nesneleri'ni (rmo)

SQL Server Management Studio Kullanarak

Çekme abonelik sırasında yayımcı silmek (dan Yerel yayınları klasöründe SQL Server Management Studio) veya abone (dan Yerel Abonelikleri klasörü). Bir abonelik silme nesnelerini veya veri abonelik kaldırmaz; onlar el ile kaldırılması gerekir.

Çekme abonelik sırasında yayımcı silmek için

  1. Yayımcı bağlanmak SQL Server Management Studiove sonra sunucu düğümünü genişletin.

  2. Genişletme çoğaltma klasörünü ve ardından Yerel yayınları klasörü.

  3. Silmek istediğiniz abonelik ile ilişkilendirilmiş yayın genişletin.

  4. Abonelik sağ tıklatın ve ardından silmek.

  5. Onay iletişim kutusunda abonelik bilgilerini silmek için abone bağlanmak seçin. Temizlerseniz abone bağlanma onay kutusunu, daha sonra bilgileri silmek için abone bağlanmak.

Çekme abonelik abone adresindeki silmek için

  1. Abone bağlanmak SQL Server Management Studiove sonra sunucu düğümünü genişletin.

  2. Genişletme çoğaltma klasörünü ve ardından Yerel Abonelikleri klasörü.

  3. Silin ve ardından istediğiniz abonelik sağ silmek.

  4. Onay iletişim kutusunda abonelik bilgilerini silmek için yayımcı bağlanmak seçin. Temizlerseniz Publisher bağlanma onay kutusunu sonra bilgileri silmek için yayımcı bağlanmak.

Başa Dön bağlantısıyla kullanılan ok simgesi[Top]

Transact-SQL'i Kullanma

Çekme abonelikleri çoğaltma depolanmış yordamları kullanarak programsal silinebilir. Kullanılan saklı yordamlar abonelik ait olduğu yayın türüne bağlıdır.

Anlık görüntü veya işlem yayın için çekme Abonelik silmek için

  1. Abone veritabanı Abone tarafında idam sp_droppullsubscription (Transact-sql). Belirtmek @ yayın, @ publisher, ve @ publisher_db.

  2. Yayını veritabanı üzerinde Yayımcı tarafında idam sp_dropsubscription (Transact-sql). Belirtmek @ yayın ve @ abone. Değeri belirtmeniz tüm için @ makale. (İsteğe bağlı) Dağıtımcı erişilemiyorsa, değeri belirtmeniz 1 için @ ignore_distributor abonelik dağıtımcı ilişkili nesneleri kaldırmadan silmek için.

Çekme abonelik birleştirme yayınına silmek için

  1. Abone veritabanı Abone tarafında idam sp_dropmergepullsubscription (Transact-sql). Belirtmek @ yayın, @ publisher, ve @ publisher_db.

  2. Yayını veritabanı üzerinde Yayımcı tarafında idam sp_dropmergesubscription (Transact-sql). Belirtmek @ yayın, @ abone, ve @ subscriber_db. Değeri belirtmeniz Tanıtım için @ subscription_type. (İsteğe bağlı) Dağıtımcı erişilemiyorsa, değeri belirtmeniz 1 için @ ignore_distributor abonelik dağıtımcı ilişkili nesneleri kaldırmadan silmek için.

Örnekler (Transact-SQL)

Aşağıdaki örnek, bir çekme abonelik işlem yayınına siler. İlk toplu abone adresindeki yürütülür ve ikinci yayımcı adresindeki yürütülür.

-- 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

-- 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 [AdventureWorks2012]
EXEC sp_dropsubscription 
  @publication = @publication, 
  @article = N'all',
  @subscriber = @subscriber;
GO

Aşağıdaki örnek, bir çekme abonelik birleştirme yayınına siler. İlk toplu abone adresindeki yürütülür ve ikinci yayımcı adresindeki yürütülür.

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

USE [AdventureWorks2012Replica]
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'AdventureWorks2012Replica';

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

Başa Dön bağlantısıyla kullanılan ok simgesi[Top]

Çoğaltma Yönetimi Nesneleri'ni (rmo) kullanarak

Çoğaltma Yönetimi Nesneleri'ni (rmo) kullanarak programlı olarak çekme abonelikleri silebilirsiniz. Çekme abonelik silmek için kullanılan rmo sınıflar için çekme abonelik abone yayın türüne bağlıdır.

Anlık görüntü veya işlem yayın için çekme Abonelik silmek için

  1. Publisher ve abone bağlantıları kullanarak oluşturma ServerConnectionsınıf

  2. Örneğini TransPullSubscriptionsınıf ve set PublicationName, DatabaseName, PublisherName, ve PublicationDBNameÖzellikler. Ayarlamak için adım 1'den abone bağlantı kullanın ConnectionContextözellik.

  3. Kontrol IsExistingObjectözelliği abonelik bulunduğunu doğrulamaktır. Bu özelliğin değeri ise false, adım 2 Abonelik özellikleri yanlış tanımlanan ya da abonelik yok.

  4. Arama Removeyöntemi.

  5. Örneğini TransPublicationsınıfı kullanarak Publisher bağlantı adım 1. Specify Name, DatabaseName and ConnectionContext.

  6. Arama LoadPropertiesyöntemi. Bu yöntem ise false, adım 5'de belirtilen özellikleri yanlış veya Yayını sunucuda yok.

  7. Arama RemovePullSubscriptionyöntemi. Abone ve abonelik veritabanı adı belirtmek subscriberve subscriberDBparametreleri.

Çekme abonelik birleştirme yayınına silmek için

  1. Publisher ve abone bağlantıları kullanarak oluşturma ServerConnectionsınıf

  2. Örneğini MergePullSubscriptionsınıf ve set PublicationName, DatabaseName, PublisherName, ve PublicationDBNameÖzellikler. Ayarlamak için adım 1 ' bağlantısını kullanın ConnectionContextözellik.

  3. Kontrol IsExistingObjectözelliği abonelik bulunduğunu doğrulamaktır. Bu özelliğin değeri ise false, adım 2 Abonelik özellikleri yanlış tanımlanan ya da abonelik yok.

  4. Arama Removeyöntemi.

  5. Örneğini MergePublicationsınıfı kullanarak Publisher bağlantı adım 1. Specify Name, DatabaseName and ConnectionContext.

  6. Arama LoadPropertiesyöntemi. Bu yöntem ise false, adım 5'de belirtilen özellikleri yanlış veya Yayını sunucuda yok.

  7. Arama RemovePullSubscriptionyöntemi. Abone ve abonelik veritabanı adı belirtmek subscriberve subscriberDBparametreleri.

Örnekler (rmo)

Bu örnek, bir çekme abonelik işlem yayınına siler ve yayımcı abonelik kayıtta kaldırır.

            // Define the Publisher, publication, and databases.
            string publicationName = "AdvWorksProductTran";
            string publisherName = publisherInstance;
            string subscriberName = subscriberInstance;
            string subscriptionDbName = "AdventureWorks2012Replica";
            string publicationDbName = "AdventureWorks2012";

            //Create connections to the Publisher and Subscriber.
            ServerConnection subscriberConn = new ServerConnection(subscriberName);
            ServerConnection publisherConn = new ServerConnection(publisherName);

            // Create the objects that we need.
            TransPublication publication;
            TransPullSubscription subscription;

            try
            {
                // Connect to the Subscriber.
                subscriberConn.Connect();

                // Define the pull subscription.
                subscription = new TransPullSubscription();
                subscription.ConnectionContext = subscriberConn;
                subscription.PublisherName = publisherName;
                subscription.PublicationName = publicationName;
                subscription.PublicationDBName = publicationDbName;
                subscription.DatabaseName = subscriptionDbName;

                // Define the publication.
                publication = new TransPublication();
                publication.Name = publicationName;
                publication.DatabaseName = publicationDbName;
                publication.ConnectionContext = publisherConn;

                // Delete the pull subscription, if it exists.
                if (subscription.IsExistingObject)
                {
                    if (publication.LoadProperties())
                    {
                        // Remove the pull subscription registration at the Publisher.
                        publication.RemovePullSubscription(subscriberName, subscriptionDbName);
                    }
                    else
                    {
                        // Do something here if the publication does not exist.
                        throw new ApplicationException(String.Format(
                            "The publication '{0}' does not exist on {1}.",
                            publicationName, publisherName));
                    }
                    // Delete the pull subscription at the Subscriber.
                    subscription.Remove();
                }
                else
                {
                    throw new ApplicationException(String.Format(
                        "The subscription to {0} does not exist on {1}",
                        publicationName, subscriberName));
                }
            }
            catch (Exception ex)
            {
                // Implement the appropriate error handling here.
                throw new ApplicationException(String.Format(
                    "The subscription to {0} could not be deleted.", publicationName), ex);
            }
            finally
            {
                subscriberConn.Disconnect();
                publisherConn.Disconnect();
            }
' Define the Publisher, publication, and databases.
Dim publicationName As String = "AdvWorksProductTran"
Dim publisherName As String = publisherInstance
Dim subscriberName As String = subscriberInstance
Dim subscriptionDbName As String = "AdventureWorks2012Replica"
Dim publicationDbName As String = "AdventureWorks2012"

'Create connections to the Publisher and Subscriber.
Dim subscriberConn As ServerConnection = New ServerConnection(subscriberName)
Dim publisherConn As ServerConnection = New ServerConnection(publisherName)

' Create the objects that we need.
Dim publication As TransPublication
Dim subscription As TransPullSubscription

Try
    ' Connect to the Subscriber.
    subscriberConn.Connect()

    ' Define the pull subscription.
    subscription = New TransPullSubscription()
    subscription.ConnectionContext = subscriberConn
    subscription.PublisherName = publisherName
    subscription.PublicationName = publicationName
    subscription.PublicationDBName = publicationDbName
    subscription.DatabaseName = subscriptionDbName

    ' Define the publication.
    publication = New TransPublication()
    publication.Name = publicationName
    publication.DatabaseName = publicationDbName
    publication.ConnectionContext = publisherConn

    ' Delete the pull subscription, if it exists.
    If subscription.IsExistingObject Then

        If publication.LoadProperties() Then
            ' Remove the pull subscription registration at the Publisher.
            publication.RemovePullSubscription(subscriberName, subscriptionDbName)
        Else
            ' Do something here if the publication does not exist.
            Throw New ApplicationException(String.Format( _
             "The publication '{0}' does not exist on {1}.", _
             publicationName, publisherName))
        End If
        ' Delete the pull subscription at the Subscriber.
        subscription.Remove()
    Else
        Throw New ApplicationException(String.Format( _
         "The subscription to {0} does not exist on {1}", _
         publicationName, subscriberName))
    End If
Catch ex As Exception
    ' Implement the appropriate error handling here.
    Throw New ApplicationException(String.Format( _
        "The subscription to {0} could not be deleted.", publicationName), ex)
Finally
    subscriberConn.Disconnect()
    publisherConn.Disconnect()
End Try

Bu örnek, bir çekme abonelik birleştirme yayınına siler ve yayımcı abonelik kayıtta kaldırır.

         // Define the Publisher, publication, and databases.
            string publicationName = "AdvWorksSalesOrdersMerge";
            string publisherName = publisherInstance;
            string subscriberName = subscriberInstance;
            string subscriptionDbName = "AdventureWorks2012Replica";
            string publicationDbName = "AdventureWorks2012";

            //Create connections to the Publisher and Subscriber.
            ServerConnection subscriberConn = new ServerConnection(subscriberName);
            ServerConnection publisherConn = new ServerConnection(publisherName);

            // Create the objects that we need.
            MergePublication publication;
            MergePullSubscription subscription;

            try
            {
                // Connect to the Subscriber.
                subscriberConn.Connect();

                // Define the pull subscription.
                subscription = new MergePullSubscription();
                subscription.ConnectionContext = subscriberConn;
                subscription.PublisherName = publisherName;
                subscription.PublicationName = publicationName;
                subscription.PublicationDBName = publicationDbName;
                subscription.DatabaseName = subscriptionDbName;

                // Define the publication.
                publication = new MergePublication();
                publication.Name = publicationName;
                publication.DatabaseName = publicationDbName;
                publication.ConnectionContext = publisherConn;

                // Delete the pull subscription, if it exists.
                if (subscription.IsExistingObject)
                {
                    // Delete the pull subscription at the Subscriber.
                    subscription.Remove();

                    if (publication.LoadProperties())
                    {
                        publication.RemovePullSubscription(subscriberName, subscriptionDbName);
                    }
                    else
                    {
                        // Do something here if the publication does not exist.
                        throw new ApplicationException(String.Format(
                            "The publication '{0}' does not exist on {1}.",
                            publicationName, publisherName));
                    }
                }
                else
                {
                    throw new ApplicationException(String.Format(
                        "The subscription to {0} does not exist on {1}",
                        publicationName, subscriberName));
                }
            }
            catch (Exception ex)
            {
                // Implement the appropriate error handling here.
                throw new ApplicationException(String.Format(
                    "The subscription to {0} could not be deleted.", publicationName), ex);
            }
            finally
            {
                subscriberConn.Disconnect();
                publisherConn.Disconnect();
            }
' Define the Publisher, publication, and databases.
Dim publicationName As String = "AdvWorksSalesOrdersMerge"
Dim publisherName As String = publisherInstance
Dim subscriberName As String = subscriberInstance
Dim subscriptionDbName As String = "AdventureWorks2012Replica"
Dim publicationDbName As String = "AdventureWorks2012"

'Create connections to the Publisher and Subscriber.
Dim subscriberConn As ServerConnection = New ServerConnection(subscriberName)
Dim publisherConn As ServerConnection = New ServerConnection(publisherName)

' Create the objects that we need.
Dim publication As MergePublication
Dim subscription As MergePullSubscription

Try
    ' Connect to the Subscriber.
    subscriberConn.Connect()

    ' Define the pull subscription.
    subscription = New MergePullSubscription()
    subscription.ConnectionContext = subscriberConn
    subscription.PublisherName = publisherName
    subscription.PublicationName = publicationName
    subscription.PublicationDBName = publicationDbName
    subscription.DatabaseName = subscriptionDbName

    ' Define the publication.
    publication = New MergePublication()
    publication.Name = publicationName
    publication.DatabaseName = publicationDbName
    publication.ConnectionContext = publisherConn

    ' Delete the pull subscription, if it exists.
    If subscription.IsExistingObject Then

        ' Delete the pull subscription at the Subscriber.
        subscription.Remove()

        If publication.LoadProperties() Then
            publication.RemovePullSubscription(subscriberName, subscriptionDbName)
        Else
            ' Do something here if the publication does not exist.
            Throw New ApplicationException(String.Format( _
             "The publication '{0}' does not exist on {1}.", _
             publicationName, publisherName))
        End If
    Else
        Throw New ApplicationException(String.Format( _
         "The subscription to {0} does not exist on {1}", _
         publicationName, subscriberName))
    End If
Catch ex As Exception
    ' Implement the appropriate error handling here.
    Throw New ApplicationException(String.Format( _
        "The subscription to {0} could not be deleted.", publicationName), ex)
Finally
    subscriberConn.Disconnect()
    publisherConn.Disconnect()
End Try

Başa Dön bağlantısıyla kullanılan ok simgesi[Top]

Ayrıca bkz.

Kavramlar

Yayınlara abone

ModeliveÇoğaltma güvenlik en iyi uygulamalar