적용 대상: SQL Server
Azure SQL Managed Instance
테이블 아티클을 기반으로 게시된 데이터를 필터링합니다. 이 저장 프로시저는 게시 데이터베이스의 게시자에서 실행됩니다.
구문
sp_articlefilter
[ @publication = ] N'publication'
, [ @article = ] N'article'
[ , [ @filter_name = ] N'filter_name' ]
[ , [ @filter_clause = ] N'filter_clause' ]
[ , [ @force_invalidate_snapshot = ] force_invalidate_snapshot ]
[ , [ @force_reinit_subscription = ] force_reinit_subscription ]
[ , [ @publisher = ] N'publisher' ]
[ ; ]
인수
[ @publication = ] N'publication'
아티클을 포함하는 게시의 이름입니다. @publication 기본값이 없는 sysname입니다.
[ @article = ] N'article'
아티클의 이름입니다. @article 기본값이 없는 sysname입니다.
[ @filter_name = ] N'filter_name'
@filter_name 만들 필터 저장 프로시저의 이름입니다. @filter_name 기본값NULL인 nvarchar(517)입니다. 고유한 아티클 필터의 이름을 지정해야 합니다.
[ @filter_clause = ] N'filter_clause'
가로 필터를 정의하는 restriction(WHERE) 절입니다. 제한 절을 입력할 때 키워드 WHERE를 생략합니다. @filter_clause 기본값NULL인 nvarchar(max)입니다.
[ @force_invalidate_snapshot = ] force_invalidate_snapshot
이 저장 프로시저에서 수행한 작업이 기존 스냅샷을 무효화할 수 있음을 인정합니다. @force_invalidate_snapshot 비트이며 기본값은 .입니다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 게시자에 사용하면 안 됩니다.
반환 코드 값
0(성공) 또는 1(실패).
설명
sp_articlefilter 는 스냅샷 복제 및 트랜잭션 복제에 사용됩니다.
sp_articlefilter 기존 구독을 사용하여 아티클을 실행하려면 해당 구독을 다시 초기화해야 합니다.
sp_articlefilter는 필터를 만들고 sysarticles 테이블의 열에 filter 필터 저장 프로시저의 ID를 삽입한 다음 열에 filter_clause 제한 절의 텍스트를 삽입합니다.
가로 필터를 사용하여 아티클을 만들려면 @filter_name 매개 변수 없이 sp_addarticle 실행합니다. @filter_clause sp_articlefilter포함한 모든 매개 변수를 제공하고 sp_articleview 실행하여 동일한 @filter_clause 포함한 모든 매개 변수를 제공합니다. 필터가 이미 있고 in sysarticles 이 1 (로그 기반 아티클)이면 type 이전 필터가 삭제되고 새 필터가 만들어집니다.
@filter_name 및 @filter_clause 제공되지 않으면 이전 필터가 삭제되고 필터 ID가 로 0설정됩니다.
예제
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_articlefilter수 있습니다.