Publication.Remove Publication.Remove Publication.Remove Method

정의

기존 게시를 제거합니다. Removes an existing publication.

오버로드

Remove() Remove() Remove()

기존 게시를 제거합니다. Removes an existing publication.

Remove(Boolean) Remove(Boolean) Remove(Boolean)

배포자에 액세스할 수 없는 경우에도 기존 게시를 제거합니다. Removes an existing publication even if the Distributor cannot be accessed.

예제

이 예에서는 트랜잭션 게시를 삭제 합니다.This example deletes a transactional publication.

// Define the Publisher, publication database, 
// and publication names.
string publisherName = publisherInstance;
string publicationName = "AdvWorksProductTran";
string publicationDbName = "AdventureWorks2012";

TransPublication publication;
ReplicationDatabase publicationDb;

// Create a connection to the Publisher 
// using Windows Authentication.
ServerConnection conn = new ServerConnection(publisherName);

try
{
	conn.Connect();

	// Set the required properties for the transactional publication.
	publication = new TransPublication();
	publication.ConnectionContext = conn;
	publication.Name = publicationName;
	publication.DatabaseName = publicationDbName;

	// Delete the publication, if it exists and has no subscriptions.
	if (publication.LoadProperties() && !publication.HasSubscription)
	{
		publication.Remove();
	}
	else
	{
		// Do something here if the publication does not exist
		// or has subscriptions.
		throw new ApplicationException(String.Format(
			"The publication {0} could not be deleted. " +
			"Ensure that the publication exists and that all " +
			"subscriptions have been deleted.",
			publicationName, publisherName));
	}

	// If no other transactional publications exists,
	// disable publishing on the database.
	publicationDb = new ReplicationDatabase(publicationDbName, conn);
	if (publicationDb.LoadProperties())
	{
		if (publicationDb.TransPublications.Count == 0)
		{
			publicationDb.EnabledTransPublishing = false;
		}
	}
	else
	{
		// Do something here if the database does not exist.
		throw new ApplicationException(String.Format(
			"The database {0} does not exist on {1}.",
			publicationDbName, publisherName));
	}
}
catch (Exception ex)
{
	// Implement application error handling here.
	throw new ApplicationException(String.Format(
		"The publication {0} could not be deleted.",
		publicationName), ex);
}
finally
{
	conn.Disconnect();
}
' Define the Publisher, publication database, 
' and publication names.
Dim publisherName As String = publisherInstance
Dim publicationName As String = "AdvWorksProductTran"
Dim publicationDbName As String = "AdventureWorks2012"

Dim publication As TransPublication
Dim publicationDb As ReplicationDatabase

' Create a connection to the Publisher 
' using Windows Authentication.
Dim conn As ServerConnection = New ServerConnection(publisherName)

Try
    conn.Connect()

    ' Set the required properties for the transactional publication.
    publication = New TransPublication()
    publication.ConnectionContext = conn
    publication.Name = publicationName
    publication.DatabaseName = publicationDbName

    ' Delete the publication, if it exists and has no subscriptions.
    If publication.LoadProperties() And Not publication.HasSubscription Then
        publication.Remove()
    Else
        ' Do something here if the publication does not exist
        ' or has subscriptions.
        Throw New ApplicationException(String.Format( _
         "The publication {0} could not be deleted. " + _
         "Ensure that the publication exists and that all " + _
         "subscriptions have been deleted.", _
         publicationName, publisherName))
    End If

    ' If no other transactional publications exists,
    ' disable publishing on the database.
    publicationDb = New ReplicationDatabase(publicationDbName, conn)
    If publicationDb.LoadProperties() Then
        If publicationDb.TransPublications.Count = 0 Then
            publicationDb.EnabledTransPublishing = False
        End If
    Else
        ' Do something here if the database does not exist.
        Throw New ApplicationException(String.Format( _
         "The database {0} does not exist on {1}.", _
         publicationDbName, publisherName))
    End If
Catch ex As Exception
    ' Implement application error handling here.
    Throw New ApplicationException(String.Format( _
     "The publication {0} could not be deleted.", _
     publicationName), ex)
Finally
    conn.Disconnect()
End Try

이 예에서는 병합 게시를 삭제 합니다.This example deletes a merge publication.

// Define the Publisher, publication database, 
// and publication names.
string publisherName = publisherInstance;
string publicationName = "AdvWorksSalesOrdersMerge";
string publicationDbName = "AdventureWorks2012";

MergePublication publication;
ReplicationDatabase publicationDb;

// Create a connection to the Publisher.
ServerConnection conn = new ServerConnection(publisherName);

try
{
	// Connect to the Publisher.
	conn.Connect();

	// Set the required properties for the merge publication.
	publication = new MergePublication();
	publication.ConnectionContext = conn;
	publication.Name = publicationName;
	publication.DatabaseName = publicationDbName;

	// Delete the publication, if it exists and has no subscriptions.
	if (publication.LoadProperties() && !publication.HasSubscription)
	{
		publication.Remove();
	}
	else
	{
		// Do something here if the publication does not exist
		// or has subscriptions.
		throw new ApplicationException(String.Format(
			"The publication {0} could not be deleted. " +
			"Ensure that the publication exists and that all " +
			"subscriptions have been deleted.",
			publicationName, publisherName));
	}

	// If no other merge publications exists,
	// disable publishing on the database.
	publicationDb = new ReplicationDatabase(publicationDbName, conn);
	if (publicationDb.LoadProperties())
	{
		if (publicationDb.MergePublications.Count == 0 && publicationDb.EnabledMergePublishing)
		{
			publicationDb.EnabledMergePublishing = false;
		}
	}
	else
	{
		// Do something here if the database does not exist.
		throw new ApplicationException(String.Format(
			"The database {0} does not exist on {1}.",
			publicationDbName, publisherName));
	}
}
catch (Exception ex)
{
	// Implement application error handling here.
	throw new ApplicationException(String.Format(
		"The publication {0} could not be deleted.",
		publicationName), ex);
}
finally
{
	conn.Disconnect();
}
' Define the Publisher, publication database, 
' and publication names.
Dim publisherName As String = publisherInstance
Dim publicationName As String = "AdvWorksSalesOrdersMerge"
Dim publicationDbName As String = "AdventureWorks2012"

Dim publication As MergePublication
Dim publicationDb As ReplicationDatabase

' Create a connection to the Publisher.
Dim conn As ServerConnection = New ServerConnection(publisherName)

Try
    ' Connect to the Publisher.
    conn.Connect()

    ' Set the required properties for the merge publication.
    publication = New MergePublication()
    publication.ConnectionContext = conn
    publication.Name = publicationName
    publication.DatabaseName = publicationDbName

    ' Delete the publication, if it exists and has no subscriptions.
    If (publication.LoadProperties() And Not publication.HasSubscription) Then
        publication.Remove()
    Else
        ' Do something here if the publication does not exist
        ' or has subscriptions.
        Throw New ApplicationException(String.Format( _
         "The publication {0} could not be deleted. " + _
         "Ensure that the publication exists and that all " + _
         "subscriptions have been deleted.", _
         publicationName, publisherName))
    End If

    ' If no other merge publications exists,
    ' disable publishing on the database.
    publicationDb = New ReplicationDatabase(publicationDbName, conn)
    If publicationDb.LoadProperties() Then
        If publicationDb.MergePublications.Count = 0 _
        And publicationDb.EnabledMergePublishing Then
            publicationDb.EnabledMergePublishing = False
        End If
    Else
        ' Do something here if the database does not exist.
        Throw New ApplicationException(String.Format( _
         "The database {0} does not exist on {1}.", _
         publicationDbName, publisherName))
    End If
Catch ex As Exception
    ' Implement application error handling here.
    Throw New ApplicationException(String.Format( _
     "The publication {0} could not be deleted.", _
     publicationName), ex)
Finally
    conn.Disconnect()
End Try

Remove() Remove() Remove()

기존 게시를 제거합니다. Removes an existing publication.

public:
 void Remove();
public void Remove ();
Public Sub Remove ()

예제

이 예에서는 트랜잭션 게시를 삭제 합니다.This example deletes a transactional publication.

// Define the Publisher, publication database, 
// and publication names.
string publisherName = publisherInstance;
string publicationName = "AdvWorksProductTran";
string publicationDbName = "AdventureWorks2012";

TransPublication publication;
ReplicationDatabase publicationDb;

// Create a connection to the Publisher 
// using Windows Authentication.
ServerConnection conn = new ServerConnection(publisherName);

try
{
	conn.Connect();

	// Set the required properties for the transactional publication.
	publication = new TransPublication();
	publication.ConnectionContext = conn;
	publication.Name = publicationName;
	publication.DatabaseName = publicationDbName;

	// Delete the publication, if it exists and has no subscriptions.
	if (publication.LoadProperties() && !publication.HasSubscription)
	{
		publication.Remove();
	}
	else
	{
		// Do something here if the publication does not exist
		// or has subscriptions.
		throw new ApplicationException(String.Format(
			"The publication {0} could not be deleted. " +
			"Ensure that the publication exists and that all " +
			"subscriptions have been deleted.",
			publicationName, publisherName));
	}

	// If no other transactional publications exists,
	// disable publishing on the database.
	publicationDb = new ReplicationDatabase(publicationDbName, conn);
	if (publicationDb.LoadProperties())
	{
		if (publicationDb.TransPublications.Count == 0)
		{
			publicationDb.EnabledTransPublishing = false;
		}
	}
	else
	{
		// Do something here if the database does not exist.
		throw new ApplicationException(String.Format(
			"The database {0} does not exist on {1}.",
			publicationDbName, publisherName));
	}
}
catch (Exception ex)
{
	// Implement application error handling here.
	throw new ApplicationException(String.Format(
		"The publication {0} could not be deleted.",
		publicationName), ex);
}
finally
{
	conn.Disconnect();
}
' Define the Publisher, publication database, 
' and publication names.
Dim publisherName As String = publisherInstance
Dim publicationName As String = "AdvWorksProductTran"
Dim publicationDbName As String = "AdventureWorks2012"

Dim publication As TransPublication
Dim publicationDb As ReplicationDatabase

' Create a connection to the Publisher 
' using Windows Authentication.
Dim conn As ServerConnection = New ServerConnection(publisherName)

Try
    conn.Connect()

    ' Set the required properties for the transactional publication.
    publication = New TransPublication()
    publication.ConnectionContext = conn
    publication.Name = publicationName
    publication.DatabaseName = publicationDbName

    ' Delete the publication, if it exists and has no subscriptions.
    If publication.LoadProperties() And Not publication.HasSubscription Then
        publication.Remove()
    Else
        ' Do something here if the publication does not exist
        ' or has subscriptions.
        Throw New ApplicationException(String.Format( _
         "The publication {0} could not be deleted. " + _
         "Ensure that the publication exists and that all " + _
         "subscriptions have been deleted.", _
         publicationName, publisherName))
    End If

    ' If no other transactional publications exists,
    ' disable publishing on the database.
    publicationDb = New ReplicationDatabase(publicationDbName, conn)
    If publicationDb.LoadProperties() Then
        If publicationDb.TransPublications.Count = 0 Then
            publicationDb.EnabledTransPublishing = False
        End If
    Else
        ' Do something here if the database does not exist.
        Throw New ApplicationException(String.Format( _
         "The database {0} does not exist on {1}.", _
         publicationDbName, publisherName))
    End If
Catch ex As Exception
    ' Implement application error handling here.
    Throw New ApplicationException(String.Format( _
     "The publication {0} could not be deleted.", _
     publicationName), ex)
Finally
    conn.Disconnect()
End Try

이 예에서는 병합 게시를 삭제 합니다.This example deletes a merge publication.

// Define the Publisher, publication database, 
// and publication names.
string publisherName = publisherInstance;
string publicationName = "AdvWorksSalesOrdersMerge";
string publicationDbName = "AdventureWorks2012";

MergePublication publication;
ReplicationDatabase publicationDb;

// Create a connection to the Publisher.
ServerConnection conn = new ServerConnection(publisherName);

try
{
	// Connect to the Publisher.
	conn.Connect();

	// Set the required properties for the merge publication.
	publication = new MergePublication();
	publication.ConnectionContext = conn;
	publication.Name = publicationName;
	publication.DatabaseName = publicationDbName;

	// Delete the publication, if it exists and has no subscriptions.
	if (publication.LoadProperties() && !publication.HasSubscription)
	{
		publication.Remove();
	}
	else
	{
		// Do something here if the publication does not exist
		// or has subscriptions.
		throw new ApplicationException(String.Format(
			"The publication {0} could not be deleted. " +
			"Ensure that the publication exists and that all " +
			"subscriptions have been deleted.",
			publicationName, publisherName));
	}

	// If no other merge publications exists,
	// disable publishing on the database.
	publicationDb = new ReplicationDatabase(publicationDbName, conn);
	if (publicationDb.LoadProperties())
	{
		if (publicationDb.MergePublications.Count == 0 && publicationDb.EnabledMergePublishing)
		{
			publicationDb.EnabledMergePublishing = false;
		}
	}
	else
	{
		// Do something here if the database does not exist.
		throw new ApplicationException(String.Format(
			"The database {0} does not exist on {1}.",
			publicationDbName, publisherName));
	}
}
catch (Exception ex)
{
	// Implement application error handling here.
	throw new ApplicationException(String.Format(
		"The publication {0} could not be deleted.",
		publicationName), ex);
}
finally
{
	conn.Disconnect();
}
' Define the Publisher, publication database, 
' and publication names.
Dim publisherName As String = publisherInstance
Dim publicationName As String = "AdvWorksSalesOrdersMerge"
Dim publicationDbName As String = "AdventureWorks2012"

Dim publication As MergePublication
Dim publicationDb As ReplicationDatabase

' Create a connection to the Publisher.
Dim conn As ServerConnection = New ServerConnection(publisherName)

Try
    ' Connect to the Publisher.
    conn.Connect()

    ' Set the required properties for the merge publication.
    publication = New MergePublication()
    publication.ConnectionContext = conn
    publication.Name = publicationName
    publication.DatabaseName = publicationDbName

    ' Delete the publication, if it exists and has no subscriptions.
    If (publication.LoadProperties() And Not publication.HasSubscription) Then
        publication.Remove()
    Else
        ' Do something here if the publication does not exist
        ' or has subscriptions.
        Throw New ApplicationException(String.Format( _
         "The publication {0} could not be deleted. " + _
         "Ensure that the publication exists and that all " + _
         "subscriptions have been deleted.", _
         publicationName, publisherName))
    End If

    ' If no other merge publications exists,
    ' disable publishing on the database.
    publicationDb = New ReplicationDatabase(publicationDbName, conn)
    If publicationDb.LoadProperties() Then
        If publicationDb.MergePublications.Count = 0 _
        And publicationDb.EnabledMergePublishing Then
            publicationDb.EnabledMergePublishing = False
        End If
    Else
        ' Do something here if the database does not exist.
        Throw New ApplicationException(String.Format( _
         "The database {0} does not exist on {1}.", _
         publicationDbName, publisherName))
    End If
Catch ex As Exception
    ' Implement application error handling here.
    Throw New ApplicationException(String.Format( _
     "The publication {0} could not be deleted.", _
     publicationName), ex)
Finally
    conn.Disconnect()
End Try

설명

Remove 메서드 게시자와 배포자에서 모든 게시 메타 데이터와 게시를 제거 합니다.The Remove method removes the publication and all publication metadata at the Publisher and Distributor. 사용 하 여는 Remove 메서드 값을 전달 true 배포자 오프 라인 상태 이거나 액세스할 수 없는 게시를 제거 하려면.Use the Remove method passing a value of true to remove a publication when the Distributor is offline or cannot be accessed.

Remove 메서드의 구성원만 호출할 수는 sysadmin 고정된 서버 역할의 멤버 또는 게시자에는 db_owner 게시 데이터베이스의 고정된 데이터베이스 역할입니다.The Remove method can only be called by members of the sysadmin fixed server role at the Publisher or by members of the db_owner fixed database role on the publication database.

호출 Remove 를 실행 하는 것과 같습니다 sp_droppublication (Transact SQL) 또는 sp_dropmergepublication (Transact SQL)합니다.Calling Remove is equivalent to executing sp_droppublication (Transact-SQL) or sp_dropmergepublication (Transact-SQL).

추가 정보

Remove(Boolean) Remove(Boolean) Remove(Boolean)

배포자에 액세스할 수 없는 경우에도 기존 게시를 제거합니다. Removes an existing publication even if the Distributor cannot be accessed.

public:
 void Remove(bool force);
public void Remove (bool force);
Public Sub Remove (force As Boolean)
매개 변수
force
Boolean Boolean Boolean

배포자에 액세스할 수 없는 경우에도 게시를 제거할 수 있는지 여부를 나타내는 Boolean 값입니다. A Boolean value that indicates whether or not a publication can be removed even if the Distributor cannot be accessed. 배포자가 오프라인이거나 배포자를 다시 설치하는 경우 게시를 제거하려면 true 값을 지정하십시오. Specify a value of true to remove a publication when the Distributor is offline or when reinstalling the Distributor.

설명

Remove 메서드의 구성원만 호출할 수는 sysadmin 고정된 서버 역할의 멤버 또는 게시자에는 db_owner 게시 데이터베이스의 고정된 데이터베이스 역할입니다.The Remove method can only be called by members of the sysadmin fixed server role at the Publisher or by members of the db_owner fixed database role on the publication database.

호출 Remove 를 실행 하는 것과 같습니다 sp_droppublication (Transact SQL) 또는 sp_dropmergepublication (Transact SQL)합니다.Calling Remove is equivalent to executing sp_droppublication (Transact-SQL) or sp_dropmergepublication (Transact-SQL).

적용 대상