sp_articlefilter (języka Transact-SQL)

Filtry danych, które publikowane są oparte na artykuł tabela.Ta procedura składowana jest wykonywany na Wydawca na bazie publikacja.

Ikona łącza do tematuKonwencje składni Transact-SQL

Składnia

sp_articlefilter [ @publication = ] 'publication'
        , [ @article = ] 'article'
    [ , [ @filter_name = ] 'filter_name' ]
    [ , [ @filter_clause = ] 'filter_clause' ]
    [ , [ @force_invalidate_snapshot = ] force_invalidate_snapshot ]
    [ , [ @force_reinit_subscription = ] force_reinit_subscription ]
    [ , [ @publisher = ] 'publisher' ]

Argumenty

  • [ @ publikacja = 'publication"
    Is the name of the publication that contains the article.publication is sysname, with no default.

  • [ @ artykuł = 'article"
    Is the name of the article.article is sysname, with no default.

  • [ @ nazwa_filtru = 'nazwa_filtru"
    Is the name of the filter stored procedure to be created from the filter_name.filter_name is nvarchar(386), with a default of NULL.Należy określić unikatową nazwę filtru artykuł.

  • [ @ filter_clause = 'filter_clause"
    Ograniczenie jest klauzula (gdzie) definiujący poziome filtru.When entering the restriction clause, omit the keyword WHERE.filter_clause is ntext, with a default of NULL.

  • [ @ force_invalidate_snapshot = force_invalidate_snapshot
    Acknowledges that the action taken by this stored procedure may invalidate an existing snapshot.force_invalidate_snapshot is a bit, with a default of 0.

    0 określa zmiany artykuł nie powodują migawka się nieprawidłowy.Jeżeli procedura składowana wykryje, że zmiana wymaga Nowa migawka, wystąpi błąd i nie wprowadzono żadnych zmian.

    1 Określa, że zmiany w artykuł może spowodować migawki nieprawidłowa, a w przypadku istniejących subskrypcji, wymagające Nowa migawka daje uprawnienie dla istniejących migawki oznaczony jako przestarzałe i Nowa migawka generowane.

  • [ @ force_reinit_subscription = force_reinit_subscription
    Acknowledges that the action taken by this stored procedure may require existing subscriptions to be reinitialized.force_reinit_subscription is a bit, with a default of 0.

    0 określa zmiany artykuł nie powodują potrzebę należy ponownie zainicjować subskrypcję.Jeżeli procedura składowana wykryje, że zmiana wymaga subskrypcji należy ponownie zainicjować, wystąpi błąd i nie wprowadzono żadnych zmian.

    1 Określa, że zmiany w artykuł powoduje istniejących subskrypcja należy ponownie zainicjować i daje uprawnienie dla ponownego zainicjowania subskrypcja występuje.

  • [ @publisher= ] 'publisher'
    Specifies a non-Microsoft SQL Server Publisher.publisher is sysname, with a default of NULL.

    Ostrzeżenie

    publishernie może być używana z SQL Server Wydawca.

Wartości kodów powrotnych

0 (sukces) lub 1 (błąd)

Uwagi

sp_articlefilter w replikacja migawka i replikacja transakcyjna.

Wykonywanie sp_articlefilter dla artykuł z istniejącej subskrypcji wymaga tych subskrypcji należy ponownie zainicjować.

sp_articlefilter tworzy filtr, wstawia identyfikator filtru procedura składowana w filtru kolumna sysarticles (języka Transact-SQL) tabela, a następnie wstawia tekst klauzula ograniczeń w filter_clause kolumna.

Tworzenie artykuł z filtrem poziome, wykonać sp_addarticle (języka Transact-SQL) bez filter parametru.wykonać sp_articlefilter, zapewniając wszystkie parametry, w tym filter_clause, a następnie wykonywania sp_articleview (języka Transact-SQL), zapewniających wszystkie parametry, włączając identyczne filter_clause.Jeśli filtr już istnieje i typu w sysartykułs jest 1 (na podstawie dziennika artykuł), poprzedni filtr zostanie usunięty i tworzony jest nowy filtr.

Jeśli filter_name i filter_clause są nie pod warunkiem poprzedni filtr zostanie usunięty, a identyfikator filtru jest zestaw do 0.

Przykład

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

Uprawnienia

Tylko członkowie sysadmin stała rola serwera lub db_owner ustaloną rola bazy danych można wykonać sp_articlefilter.