sp_articleview(Transact-SQL)

적용 대상:SQL ServerAzure SQL Managed Instance

테이블이 세로 또는 가로로 필터링될 때 게시된 아티클을 정의하는 뷰를 만듭니다. 이 뷰는 대상 테이블에 대한 스키마 및 데이터의 필터링된 원본으로 사용됩니다. 이 저장 프로시저로는 구독되지 않은 아티클만 수정할 수 있습니다. 이 저장 프로시저는 게시 데이터베이스의 게시자에서 실행됩니다.

Transact-SQL 구문 표기 규칙

구문

sp_articleview
    [ @publication = ] N'publication'
    , [ @article = ] N'article'
    [ , [ @view_name = ] N'view_name' ]
    [ , [ @filter_clause = ] N'filter_clause' ]
    [ , [ @change_active = ] change_active ]
    [ , [ @force_invalidate_snapshot = ] force_invalidate_snapshot ]
    [ , [ @force_reinit_subscription = ] force_reinit_subscription ]
    [ , [ @publisher = ] N'publisher' ]
    [ , [ @refreshsynctranprocs = ] refreshsynctranprocs ]
    [ , [ @internal = ] internal ]
[ ; ]

인수

[ @publication = ] N'publication'

아티클을 포함하는 게시의 이름입니다. @publication 기본값이 없는 sysname입니다.

[ @article = ] N'article'

아티클의 이름입니다. @article 기본값이 없는 sysname입니다.

[ @view_name = ] N'view_name'

게시된 아티클을 정의하는 뷰의 이름입니다. @view_name 기본값NULL인 nvarchar(386)입니다.

[ @filter_clause = ] N'filter_clause'

가로 필터를 정의하는 restriction(WHERE) 절입니다. 제한 절을 입력할 때 키워드(keyword) 생략합니다 WHERE . @filter_clause 기본값NULL인 nvarchar(max)입니다.

[ @change_active = ] change_active

구독이 있는 게시의 열을 수정할 수 있습니다. @change_active 기본값0인 int입니다.

  • 이 경우 0열이 변경되지 않습니다.
  • 이 경우 1구독이 있는 활성 아티클에서 뷰를 만들거나 다시 만들 수 있습니다.

[ @force_invalidate_snapshot = ] force_invalidate_스냅샷

이 저장 프로시저에서 수행한 작업이 기존 스냅샷 무효화할 수 있음을 인정합니다. @force_invalidate_스냅샷 비트이며 기본값은 .입니다0.

  • 0는 아티클을 변경해도 스냅샷 유효하지 않도록 지정합니다. 저장 프로시저에서 변경에 새 스냅샷 필요하다는 것을 감지하면 오류가 발생하고 변경되지 않습니다.
  • 1는 아티클을 변경하면 스냅샷 유효하지 않을 수 있으며, 새 스냅샷 필요한 기존 구독이 있는 경우 기존 스냅샷 사용되지 않는 것으로 표시되고 새 스냅샷 생성될 수 있는 권한을 부여합니다.

[ @force_reinit_subscription = ] force_reinit_subscription

이 저장 프로시저에서 수행한 작업에 기존 구독을 다시 초기화해야 할 수 있음을 인정합니다. @force_reinit_subscription 비트이며 기본값은 .입니다0.

  • 0 는 아티클을 변경해도 구독이 다시 초기화되지 않도록 지정합니다. 저장 프로시저에서 변경 내용이 구독을 다시 초기화해야 한다는 것을 감지하면 오류가 발생하고 변경되지 않습니다.
  • 1 은 아티클을 변경하면 기존 구독이 다시 초기화되도록 지정하고 구독 다시 초기화에 대한 권한을 부여합니다.

[ @publisher = ] N'publisher'

SQL Server가 아닌 게시자를 지정합니다. @publisher sysname이며 기본값은 .입니다NULL.

@PUBLISHER SQL Server 게시자에서 게시할 때 사용하면 안 됩니다.

[ @refreshsynctranprocs = ] refreshsynctranprocs

복제본(replica)tion을 동기화하는 데 사용되는 저장 프로시저가 자동으로 다시 만들어지는지 여부를 지정합니다. @refreshsynctranprocs 비트이며 기본값은 .입니다1.

  • 1 는 저장 프로시저가 다시 생성됨을 의미합니다.
  • 0 는 저장 프로시저가 다시 만들어지지 않음을 의미합니다.

[ @internal = ] internal

정보를 제공하기 위해서만 확인됩니다. 지원 안 됨 향후 호환성은 보장되지 않습니다.

반환 코드 값

0 (성공) 또는 1 (실패).

설명

sp_articleview는 게시된 아티클을 정의하고 이 뷰 sync_objid 의 ID를 sysarticles(Transact-SQL) 테이블의 열에 삽입하고 열에 filter_clause 제한 절의 텍스트를 삽입하는 뷰를 만듭니다. 모든 열이 복제본(replica)ted이고 없는 filter_clausesync_objid경우 sysarticles(Transact-SQL) 테이블은 기본 테이블의 ID로 설정되며 이 테이블의 sp_articleview 사용은 필요하지 않습니다.

세로로 필터링된 테이블(즉, 열을 필터링하려면)을 먼저 @sync_object 매개 변수 없이 실행 sp_addarticle 하려면 각 열에 대해 sp_articlecolumn(Transact-SQL)를 한 번 실행하여 복제본(replica)ted(세로 필터 정의)한 다음, 실행 sp_articleview 하여 게시된 아티클을 정의하는 뷰를 만듭니다.

행을 필터링하기 위해 가로로 필터링된 테이블을 게시하려면 @filter_name 매개 변수 없이 sp_addarticle(Transact-SQL)를 실행합니다. sp_articlefilter(Transact-SQL)를 실행하여 @filter_clause 포함한 모든 매개 변수를 제공합니다. 그런 다음 동일한 @filter_clause 포함한 모든 매개 변수를 제공하여 실행sp_articleview합니다.

세로 및 가로로 필터링된 테이블을 게시하려면 @sync_object 또는 @filter_name 매개 변수 없이 sp_addarticle(Transact-SQL)를 실행합니다. 각 열을 복제본(replica)ted할 sp_articlecolumn(Transact-SQL)를 한 번 실행한 다음, sp_articlefilter(Transact-SQL)sp_articleview.

아티클에 게시된 아티클 sp_articleview 을 정의하는 뷰가 이미 있는 경우 기존 보기를 삭제하고 자동으로 새 보기를 만듭니다. 뷰를 수동으로 만든 경우(typesysarticles(Transact-SQL)) 기존 보기는 5삭제되지 않습니다.

사용자 지정 필터 저장 프로시저와 게시된 아티클을 수동으로 정의하는 뷰를 만드는 경우 실행 sp_articleview하지 마세요. 대신 이러한 값을 적절한@type 값과 함께 sp_addarticle @filter_name 및@sync_object 매개 변수(Transact-SQL)로 제공합니다.

예제

DECLARE @publication    AS sysname;
DECLARE @table AS sysname;
DECLARE @filterclause AS nvarchar(500);
DECLARE @filtername AS nvarchar(386);
DECLARE @schemaowner AS sysname;
SET @publication = N'AdvWorksProductTran'; 
SET @table = N'Product';
SET @filterclause = N'[DiscontinuedDate] IS NULL'; 
SET @filtername = N'filter_out_discontinued';
SET @schemaowner = N'Production';

-- Add a horizontally and vertically filtered article for the Product table.
-- Manually set @schema_option to ensure that the Production schema 
-- is generated at the Subscriber (0x8000000).
EXEC sp_addarticle 
    @publication = @publication, 
    @article = @table, 
    @source_object = @table,
    @source_owner = @schemaowner, 
    @schema_option = 0x80030F3,
    @vertical_partition = N'true', 
    @type = N'logbased',
    @filter_clause = @filterclause;

-- (Optional) Manually call the stored procedure to create the 
-- horizontal filtering stored procedure. Since the type is 
-- 'logbased', this stored procedures is executed automatically.
EXEC sp_articlefilter 
    @publication = @publication, 
    @article = @table, 
    @filter_clause = @filterclause, 
    @filter_name = @filtername;

-- Add all columns to the article.
EXEC sp_articlecolumn 
    @publication = @publication, 
    @article = @table;

-- Remove the DaysToManufacture column from the article
EXEC sp_articlecolumn 
    @publication = @publication, 
    @article = @table, 
    @column = N'DaysToManufacture', 
    @operation = N'drop';

-- (Optional) Manually call the stored procedure to create the 
-- vertical filtering view. Since the type is 'logbased', 
-- this stored procedures is executed automatically.
EXEC sp_articleview 
    @publication = @publication, 
    @article = @table,
    @filter_clause = @filterclause;
GO

사용 권한

sysadmin 고정 서버 역할 또는 db_owner 고정 데이터베이스 역할의 멤버만 실행할 sp_articleview수 있습니다.