게시 속성 보기 및 수정

적용 대상:SQL ServerAzure SQL Managed Instance

이 항목에서는 SQL Server Management Studio, Transact-SQL 또는 RMO(복제 관리 개체)를 사용하여 SQL Server에서 게시 속성을 보고 수정하는 방법에 대해 설명합니다.

항목 내용

시작하기 전에

제한 사항

  • 게시를 만든 후에는 일부 속성을 수정할 수 없으며 게시에 대한 구독이 있는 경우에는 다른 속성을 수정할 수 없습니다. 수정할 수 없는 속성은 읽기 전용으로 표시됩니다.

권장 사항

SQL Server Management Studio 사용

게시 속성 - <> 게시 대화 상자에서 게시 속성을 보고 수정합니다. 이 대화 상자는 SQL Server Management Studio 및 복제 모니터에서 사용할 수 있습니다. 복제 모니터를 시작하는 방법은 복제 모니터 시작을 참조하세요.

게시 속성 - <게시> 대화 상자에는 다음 페이지가 포함됩니다.

  • 일반 페이지에는 게시 이름 및 설명, 데이터베이스 이름, 게시 유형 및 구독 만료 설정이 포함되어 있습니다.

  • 아티클 페이지는 새 게시 마법사의 아티클 페이지에 해당합니다. 이 페이지를 사용하여 아티클을 추가 및 삭제하고 아티클의 속성 및 열 필터링을 변경할 수 있습니다.

  • 필터 페이지는 새 게시 마법사의 테이블 행 필터 페이지에 해당합니다. 이 페이지를 사용하여 모든 유형의 게시에 대한 정적 행 필터를 추가, 편집 및 삭제하고 병합 게시에 대한 매개 변수가 있는 행 필터 및 조인 필터를 추가, 편집 및 삭제할 수 있습니다.

  • 스냅샷 페이지를 사용하면 스냅샷의 형식 및 위치, 스냅샷의 압축 여부 및 스냅샷이 적용되기 전과 후에 실행할 스크립트를 지정할 수 있습니다.

  • FTP 스냅샷 페이지(스냅샷 및 트랜잭션 게시의 경우, SQL Server 2005 이전 버전을 실행하는 게시자에 대한 병합 게시)를 사용하면 구독자가 FTP(파일 전송 프로토콜)를 통해 스냅샷 파일을 다운로드할 수 있는지 여부를 지정할 수 있습니다.

  • FTP 스냅샷 및 인터넷 페이지(SQL Server 2005 이상을 실행하는 게시자의 병합 게시용)를 사용하면 구독자가 FTP를 통해 스냅샷 파일을 다운로드할 수 있는지 여부와 구독자가 HTTPS를 통해 구독을 동기화할 수 있는지 여부를 지정할 수 있습니다.

  • 구독 옵션 페이지에서는 모든 구독에 적용되는 다양한 옵션을 설정할 수 있습니다. 사용할 수 있는 옵션은 게시 유형에 따라 달라집니다.

  • 게시 액세스 목록 페이지에서 게시에 액세스할 수 있는 로그인 및 그룹을 지정할 수 있습니다.

  • 에이전트 보안 페이지에서는 다음 에이전트가 실행되는 계정에 대한 설정에 액세스하고 모든 게시에 대한 스냅샷 에이전트, 모든 트랜잭션 게시에 대한 로그 판독기 에이전트 및 지연 업데이트 구독을 허용하는 트랜잭션 게시에 대한 큐 판독기 에이전트와 같은 복제본(replica)tion 토폴로지의 컴퓨터에 연결할 수 있습니다.

  • 데이터 파티션 페이지(SQL Server 2005 이후 버전을 실행하는 게시자의 병합 게시의 경우)를 사용하면 매개 변수가 있는 필터가 있는 게시에 대한 구독자가 스냅샷을 사용할 수 없는 경우 스냅샷을 요청할 수 있는지 여부를 지정할 수 있습니다. 또한 한 번 또는 되풀이 일정에 따라 하나 이상의 파티션에 대한 스냅샷 생성할 수 있습니다.

Management Studio에서 게시 속성을 보고 수정하려면

  1. Management Studio에서 게시자에 커넥트 서버 노드를 확장합니다.

  2. 복제 폴더를 확장한 다음 로컬 게시 폴더를 확장합니다.

  3. 게시를 마우스 오른쪽 단추로 클릭한 다음 속성을 클릭합니다.

  4. 필요한 경우 속성을 수정한 다음 확인을 클릭합니다.

복제 모니터에서 게시 속성을 보고 수정하려면

  1. 복제 모니터의 왼쪽 창에서 게시자 그룹을 확장한 다음 게시자를 확장합니다.

  2. 게시를 마우스 오른쪽 단추로 클릭한 다음 속성을 클릭합니다.

  3. 필요한 경우 속성을 수정한 다음 확인을 클릭합니다.

Transact-SQL 사용

게시를 수정할 수 있으며 해당 속성은 복제본(replica)tion 저장 프로시저를 사용하여 프로그래밍 방식으로 반환됩니다. 사용하는 저장 프로시저는 게시 유형에 따라 달라집니다.

스냅샷 또는 트랜잭션 게시의 속성을 확인하려면

  1. @publication 매개 변수의 게시 이름을 지정하여 sp_helppublication 실행합니다. 이 매개 변수를 지정하지 않으면 게시자에 있는 모든 게시에 대한 정보가 반환됩니다.

스냅샷 또는 트랜잭션 게시의 속성을 변경하려면

  1. sp_changepublication 실행하고 @property 매개 변수에서 변경할 게시 속성과 @value 매개 변수에서 이 속성의 새 값을 지정합니다.

    참고 항목

    변경 시 새 스냅샷을 생성해야 하는 경우 @force_invalidate_snapshot 값도 1로 지정해야 합니다. 변경 시 구독자를 초기화해야 하는 경우 @force_reinit_subscription 에 값 1을 지정해야 합니다. 변경된 경우 새 스냅샷 또는 다시 초기화가 필요한 속성에 대한 자세한 내용은 게시 및 아티클 속성 변경을 참조하세요.

병합 게시의 속성을 보려면

  1. @publication 매개 변수의 게시 이름을 지정하여 sp_helpmergepublication 실행합니다. 이 매개 변수를 지정하지 않으면 게시자에 있는 모든 게시에 대한 정보가 반환됩니다.

병합 게시의 속성을 변경하려면

  1. sp_changemergepublication 실행하고 @property 매개 변수에서 변경되는 게시 속성과 @value 매개 변수에서 이 속성의 새 값을 지정합니다.

    참고 항목

    변경에 새 스냅샷 생성해야 하는 경우 @force_invalidate_스냅샷 값 1도 지정해야 하며, 변경 시 구독자를 다시 초기화해야 하는 경우 @force_reinit_subscription 1값을 지정해야 합니다. 변경될 때 새 스냅샷 또는 다시 초기화해야 하는 속성에 대한 자세한 내용은 변경 게시 및 아티클 속성을 참조하세요.

스냅샷 속성을 보려면

  1. @publication 매개 변수의 게시 이름을 지정하여 sp_helppublication_스냅샷 실행합니다.

스냅샷 속성을 변경하려면

  1. 적절한 스냅샷 매개 변수에 하나 이상의 새 스냅샷 속성을 지정하여 sp_changepublication_snapshot을 실행합니다.

예제(Transact-SQL)

이 트랜잭션 복제본(replica) 예제에서는 게시의 속성을 반환합니다.

DECLARE @myTranPub AS sysname
SET @myTranPub = N'AdvWorksProductTran' 

USE [AdventureWorks2022]
EXEC sp_helppublication @publication = @myTranPub
GO

이 트랜잭션 복제본(replica) 예제에서는 게시에 대한 스키마 복제본(replica)tion을 사용하지 않도록 설정합니다.

DECLARE @publication AS sysname
SET @publication = N'AdvWorksProductTran' 

-- Turn off DDL replication for the transactional publication.
USE [AdventureWorks2022]
EXEC sp_changepublication 
  @publication = @publication, 
  @property = N'replicate_ddl', 
  @value = 0
GO

이 병합 복제본(replica) 예제에서는 게시의 속성을 반환합니다.

DECLARE @publication AS sysname;
SET @publication = N'AdvWorksSalesOrdersMerge';

USE [AdventureWorks2022]
EXEC sp_helpmergepublication @publication = @publication;
GO

이 병합 복제본(replica)tion 예제에서는 게시에 대한 스키마 복제본(replica)tion을 사용하지 않도록 설정합니다.

DECLARE @publication AS sysname;
SET @publication = N'AdvWorksSalesOrdersMerge'; 

-- Disable DDL replication for the publication.
USE [AdventureWorks2022]
EXEC sp_changemergepublication 
  @publication = @publication, 
  @property = N'replicate_ddl', 
  @value = 0,
  @force_invalidate_snapshot = 0, 
  @force_reinit_subscription = 0;
GO

RMO(복제 관리 개체) 사용

RMO(복제 관리 개체)를 사용하여 프로그래밍 방식으로 게시를 수정하고 해당 속성에 액세스할 수 있습니다. 게시 속성을 보거나 수정하는 데 사용하는 RMO 클래스는 게시 유형에 따라 달라집니다.

스냅샷 또는 트랜잭션 게시의 속성을 보거나 수정하려면

  1. ServerConnection 클래스를 사용하여 게시자 연결을 만듭니다.

  2. TransPublication 클래스의 인스턴스를 만들고 게시에 대한 NameDatabaseName 속성을 설정한 다음, 1단계에서 만든 연결에 ConnectionContext 속성을 설정합니다.

  3. LoadProperties 메서드를 호출하여 개체 속성을 가져옵니다. 이 메서드가 false를 반환하는 경우 2단계의 게시 속성이 잘못 정의되었거나 게시가 존재하지 않습니다.

  4. (선택 사항) 속성을 변경하려면 하나 이상의 설정 가능한 속성에 대해 새 값을 설정합니다. 논리 AND 연산자(Microsoft Visual C# 및 Microsoft Visual Basic의 경우)를 사용하여 속성에 지정된 PublicationAttributesAttributes 값이 설정되어 있는지 확인합니다. 포괄 논리 OR 연산자(|Visual C# 및 또는 Visual Basic의 경우)와 전용 논리 OR 연산자(^Visual C# 및 Visual Basic의 Xor)를 사용하여 속성 값을 Attributes 변경 PublicationAttributes 합니다.

  5. (선택 사항) trueCachePropertyChanges값을 지정한 경우 메서드를 CommitPropertyChanges 호출하여 서버에서 변경 내용을 커밋합니다. (기본값)에 대해 CachePropertyChanges false 값을 지정한 경우 변경 내용이 즉시 서버로 전송됩니다.

병합 게시의 속성을 보거나 수정하려면

  1. ServerConnection 클래스를 사용하여 게시자 연결을 만듭니다.

  2. MergePublication 클래스의 인스턴스를 만들고 게시에 대한 NameDatabaseName 속성을 설정한 다음, 1단계에서 만든 연결에 ConnectionContext 속성을 설정합니다.

  3. LoadProperties 메서드를 호출하여 개체 속성을 가져옵니다. 이 메서드가 false를 반환하는 경우 2단계의 게시 속성이 잘못 정의되었거나 게시가 존재하지 않습니다.

  4. (선택 사항) 속성을 변경하려면 하나 이상의 설정 가능한 속성에 대해 새 값을 설정합니다. 논리 AND 연산자(Visual C# 및 Visual Basic에서는 And)를 사용하여 속성에 지정된 PublicationAttributesAttributes 값이 설정되어 있는지 확인합니다. 포괄 논리 OR 연산자(|Visual C# 및 또는 Visual Basic의 경우)와 전용 논리 OR 연산자(^Visual C# 및 Visual Basic의 Xor)를 사용하여 속성 값을 Attributes 변경 PublicationAttributes 합니다.

  5. (선택 사항) trueCachePropertyChanges값을 지정한 경우 메서드를 CommitPropertyChanges 호출하여 서버에서 변경 내용을 커밋합니다. (기본값)에 대해 CachePropertyChanges false 값을 지정한 경우 변경 내용이 즉시 서버로 전송됩니다.

예제(RMO)

다음은 트랜잭션 게시에 대한 게시 특성을 설정하는 예제입니다. 변경 내용은 서버에 명시적으로 전송될 때까지 캐시됩니다.

// Define the server, database, and publication names
string publisherName = publisherInstance;
string publicationName = "AdvWorksProductTran";
string publicationDbName = "AdventureWorks2022";

TransPublication publication;

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

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

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

    // Explicitly enable caching of property changes on this object.
    publication.CachePropertyChanges = true;

    // If we can't get the properties for this publication, 
    // throw an application exception.
    if (publication.LoadProperties())
    {
        // Enable support for push subscriptions and disable support 
        // for pull subscriptions.
        if ((publication.Attributes & PublicationAttributes.AllowPull) != 0)
        {
            publication.Attributes ^= PublicationAttributes.AllowPull;
        }
        if ((publication.Attributes & PublicationAttributes.AllowPush) == 0)
        {
            publication.Attributes |= PublicationAttributes.AllowPush;
        }

        // Send changes to the server.
        publication.CommitPropertyChanges();
    }
    else
    {
        throw new ApplicationException(String.Format(
            "Settings could not be retrieved for the publication. " +
            "Ensure that the publication {0} exists on {1}.",
            publicationName, publisherName));
    }
}
catch (Exception ex)
{
    // Do error handling here.
    throw new ApplicationException(
        "The publication property could not be changed.", ex);
}
finally
{
    conn.Disconnect();
}
' Define the server, database, and publication names
Dim publisherName As String = publisherInstance
Dim publicationName As String = "AdvWorksProductTran"
Dim publicationDbName As String = "AdventureWorks2022"

Dim publication As TransPublication

' 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 publication.
    publication = New TransPublication()
    publication.ConnectionContext = conn
    publication.Name = publicationName
    publication.DatabaseName = publicationDbName

    ' Explicitly enable caching of property changes on this object.
    publication.CachePropertyChanges = True

    ' If we can't get the properties for this publication, 
    ' throw an application exception.
    If publication.LoadProperties() Then
        ' Enable support for push subscriptions and disable support 
        ' for pull subscriptions.
        If (publication.Attributes And PublicationAttributes.AllowPull) <> 0 Then
            publication.Attributes = publication.Attributes _
            Xor PublicationAttributes.AllowPull
        End If
        If (publication.Attributes And PublicationAttributes.AllowPush) = 0 Then
            publication.Attributes = publication.Attributes _
            Or PublicationAttributes.AllowPush
        End If

        ' Send changes to the server.
        publication.CommitPropertyChanges()
    Else
        Throw New ApplicationException(String.Format( _
         "Settings could not be retrieved for the publication. " + _
         "Ensure that the publication {0} exists on {1}.", _
         publicationName, publisherName))
    End If
Catch ex As Exception
    ' Do error handling here.
    Throw New ApplicationException( _
        "The publication property could not be changed.", ex)
Finally
    conn.Disconnect()
End Try

다음은 병합 게시에 대해 DDL 복제본(replica)tion을 사용하지 않도록 설정하는 예제입니다.

// Define the server, database, and publication names
string publisherName = publisherInstance;
string publicationName = "AdvWorksSalesOrdersMerge";
string publicationDbName = "AdventureWorks2022";

MergePublication publication;

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

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

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


    // If we can't get the properties for this merge publication, then throw an application exception.
    if (publication.LoadProperties())
    {
        // If DDL replication is currently enabled, disable it.
        if (publication.ReplicateDdl == DdlReplicationOptions.All)
        {
            publication.ReplicateDdl = DdlReplicationOptions.None;
        }
        else
        {
            publication.ReplicateDdl = DdlReplicationOptions.All;
        }
    }
    else
    {
        throw new ApplicationException(String.Format(
            "Settings could not be retrieved for the publication. " +
            "Ensure that the publication {0} exists on {1}.",
            publicationName, publisherName));
    }
}
catch (Exception ex)
{
    // Do error handling here.
    throw new ApplicationException(
        "The publication property could not be changed.", ex);
}
finally
{
    conn.Disconnect();
}
' Define the server, database, and publication names
Dim publisherName As String = publisherInstance
Dim publicationName As String = "AdvWorksSalesOrdersMerge"
Dim publicationDbName As String = "AdventureWorks2022"

Dim publication As MergePublication

' 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 publication.
    publication = New MergePublication()
    publication.ConnectionContext = conn
    publication.Name = publicationName
    publication.DatabaseName = publicationDbName

    ' If we can't get the properties for this merge publication, then throw an application exception.
    If publication.LoadProperties() Then
        ' If DDL replication is currently enabled, disable it.
        If publication.ReplicateDdl = DdlReplicationOptions.All Then
            publication.ReplicateDdl = DdlReplicationOptions.None
        Else
            publication.ReplicateDdl = DdlReplicationOptions.All
        End If
    Else
        Throw New ApplicationException(String.Format( _
         "Settings could not be retrieved for the publication. " + _
         "Ensure that the publication {0} exists on {1}.", _
         publicationName, publisherName))
    End If
Catch ex As Exception
    ' Do error handling here.
    Throw New ApplicationException( _
        "The publication property could not be changed.", ex)
Finally
    conn.Disconnect()
End Try

참고 항목

데이터 및 데이터베이스 개체 게시
게시 및 아티클 속성 변경
게시 데이터베이스의 스키마 변경
Replication System Stored Procedures Concepts
게시에 아티클 추가 및 삭제(SQL Server Management Studio)
복제 모니터를 사용하여 정보 보기 및 태스크 수행
아티클 속성 보기 및 수정