sp_addmergefilter (języka Transact-SQL)

Dodaje nowy filtr korespondencji seryjnej do tworzenia partycji na podstawie łączyć z innej tabela.Ta procedura składowana jest wykonywany na Wydawca na bazie publikacja.

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

Składnia

sp_addmergefilter [ @publication = ] 'publication' 
        , [ @article = ] 'article' 
        , [ @filtername = ] 'filtername' 
        , [ @join_articlename = ] 'join_articlename' 
        , [ @join_filterclause = ] join_filterclause
    [ , [ @join_unique_key = ] join_unique_key ]
    [ , [ @force_invalidate_snapshot = ] force_invalidate_snapshot ]
    [ , [ @force_reinit_subscription = ] force_reinit_subscription ]
    [ , [ @filter_type = ] filter_type ]

Argumenty

  • [ @publication= ] 'publication'
    Is the name of the publication in which the merge filter is being added.publication is sysname, with no default.

  • [ @article= ] 'article'
    Is the name of the article on which the merge filter is being added.article is sysname, with no default.

  • [ @filtername= ] 'filtername'
    Is the name of the filter.filtername is a required parameter.filternameis sysname, with no default.

  • [ @join_articlename= ] 'join_articlename'
    Is the parent article to which the child article, specified by article, must be joined using the join clause specified by join_filterclause, in order to determine the rows in the child article that meet the filter criterion of the merge filter.join_articlename is sysname, with no default.Artykuł musi być w publikacja przez publication.

  • [ @join_filterclause= ] join_filterclause
    Is the join clause that must be used to join the child article specified by articleand parent article specified by join_article, in order to determine the rows qualifying the merge filter.join_filterclause is nvarchar(1000).

  • [ @join_unique_key= ] join_unique_key
    Specifies if the join between child article articleand parent article join_articleis one-to-many, one-to-one, many-to-one, or many-to-many.join_unique_key is int, with a default of 0.0 wskazuje łączyć wiele do jednego lub wiele do wielu.1 wskazuje łączyć jednego lub jeden do wielu.Wartość ta jest 1 podczas przyłączania kolumny tworzą unikatowy klucz w join_article, lub jeśli join_filterclause pomiędzy klucz obcy w article i klucz podstawowy w join_article.

    PrzestrogaPrzestroga

    Tylko ten parametr jest ustawiony na 1 Jeśli masz ograniczenie na przyłączanie do kolumna w tabela źródłowa artykuł nadrzędnego, który gwarantuje unikatowość.Jeśli join_unique_key jest zestaw do 1 niepoprawnie, może nastąpić bez zbieżności danych.

  • [ @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 0.

    0 określa zmiany artykuł korespondencji seryjnej nie spowoduje migawka się nieprawidłowy.Jeżeli procedura składowana wykryje, że zmiana wymaga Nowa migawka, wystąpi błąd i nie zostaną wprowadzone nie zmiany.

    1 Określa, że zmiany w korespondencji seryjnej 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 nie spowoduje zmiany artykuł seryjnej subskrypcja do należy ponownie zainicjować.Jeżeli procedura składowana wykryje, że zmiana wymaga subskrypcji należy ponownie zainicjować, wystąpi błąd i nie zostaną wprowadzone nie zmiany.

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

  • [ @filter_type= ] filter_type
    Specifies the type of filter being added.filter_type is tinyint, and can be one of the following values.

    Wartość

    Opis

    1

    Dołącz tylko filtr.Wymagane do obsługi SQL Server Compact 3.5 z dodatkiem SP1 abonentów.

    2

    Tylko relacje logiczne rekordu.

    3

    Obie filtr sprzężenia i relacji rekord logiczny.

    Aby uzyskać więcej informacji, zobacz Zmiany do wierszy powiązanych z rekordami logiczne grupowanie.

Wartości kodów powrotnych

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

Uwagi

sp_addmergefilter używane w replikacja scalająca.

sp_addmergefilter może być używany tylko z artykułami tabela.Widok i artykuły indeksowany widok nie są obsługiwane.

This procedure can also be used to add a logical relationship between two articles that may or may not have a join filter between them.filter_type is used to specify if the merge filter being added is a join filter, a logical relation, or both.

Aby użyć rekordów logiczne, publikacja i artykuły muszą spełniać szereg wymagań.Aby uzyskać więcej informacji, zobacz Zmiany do wierszy powiązanych z rekordami logiczne grupowanie.

Zazwyczaj ta opcja jest używana artykuł, który ma klucz obcy odniesienie do opublikowanego tabela klucz podstawowy, oraz filtr zdefiniowany w jej artykule tabela klucz podstawowy.Podzbiór wierszy klucz podstawowy jest używany do określenia klucz obcy wierszy, które są replikowane do subskrybenta.

Nie można dodać filtr łączyć między dwoma opublikowane artykuły, kiedy źródło tabele dla obu artykułów współużytkowanie tej samej nazwy obiektu tabela.W takim przypadek, nawet jeśli obie tabele są własnością różnych schematów i artykuł unikatowe nazwy, tworzenie filtr łączyć nie powiedzie się.

Podczas obu sparametryzowany filtr wierszy i w filtr łączyć są używane w artykule tabela, replikacja Określa, czy wiersz należy subskrybenta partycji.Używając funkcja filtrowania lub filtr łączyć (za pomocą lub operator), zamiast oceny przecięcia dwóch warunków (za pomocą i operator).

Przykład

DECLARE @publication AS sysname;
DECLARE @table1 AS sysname;
DECLARE @table2 AS sysname;
DECLARE @table3 AS sysname;
DECLARE @salesschema AS sysname;
DECLARE @hrschema AS sysname;
DECLARE @filterclause AS nvarchar(1000);
SET @publication = N'AdvWorksSalesOrdersMerge'; 
SET @table1 = N'Employee'; 
SET @table2 = N'SalesOrderHeader'; 
SET @table3 = N'SalesOrderDetail'; 
SET @salesschema = N'Sales';
SET @hrschema = N'HumanResources';
SET @filterclause = N'Employee.LoginID = HOST_NAME()';

-- Add a filtered article for the Employee table.
EXEC sp_addmergearticle 
  @publication = @publication, 
  @article = @table1, 
  @source_object = @table1, 
  @type = N'table', 
  @source_owner = @hrschema,
  @schema_option = 0x0004CF1,
  @description = N'article for the Employee table',
  @subset_filterclause = @filterclause;

-- Add an article for the SalesOrderHeader table that is filtered
-- based on Employee and horizontally filtered.
EXEC sp_addmergearticle 
  @publication = @publication, 
  @article = @table2, 
  @source_object = @table2, 
  @type = N'table', 
  @source_owner = @salesschema, 
  @vertical_partition = N'true',
  @schema_option = 0x0034EF1,
  @description = N'article for the SalesOrderDetail table';

-- Add an article for the SalesOrderDetail table that is filtered
-- based on SaledOrderHeader.
EXEC sp_addmergearticle 
  @publication = @publication, 
  @article = @table3, 
  @source_object = @table3, 
  @source_owner = @salesschema,
  @description = 'article for the SalesOrderHeader table', 
  @identityrangemanagementoption = N'auto', 
  @pub_identity_range = 100000, 
  @identity_range = 100, 
  @threshold = 80,
  @schema_option = 0x0004EF1;

-- Add all columns to the SalesOrderHeader article.
EXEC sp_mergearticlecolumn 
  @publication = @publication, 
  @article = @table2, 
  @force_invalidate_snapshot = 1, 
  @force_reinit_subscription = 1;

-- Remove the credit card Approval Code column.
EXEC sp_mergearticlecolumn 
  @publication = @publication, 
  @article = @table2, 
  @column = N'CreditCardApprovalCode', 
  @operation = N'drop', 
  @force_invalidate_snapshot = 1, 
  @force_reinit_subscription = 1;

-- Add a merge join filter between Employee and SalesOrderHeader.
EXEC sp_addmergefilter 
  @publication = @publication, 
  @article = @table2, 
  @filtername = N'SalesOrderHeader_Employee', 
  @join_articlename = @table1, 
  @join_filterclause = N'Employee.BusinessEntityID = SalesOrderHeader.SalesPersonID', 
  @join_unique_key = 1, 
  @filter_type = 1, 
  @force_invalidate_snapshot = 1, 
  @force_reinit_subscription = 1;

-- Add a merge join filter between SalesOrderHeader and SalesOrderDetail.
EXEC sp_addmergefilter 
  @publication = @publication, 
  @article = @table3, 
  @filtername = N'SalesOrderDetail_SalesOrderHeader', 
  @join_articlename = @table2, 
  @join_filterclause = N'SalesOrderHeader.SalesOrderID = SalesOrderDetail.SalesOrderID', 
  @join_unique_key = 1, 
  @filter_type = 1, 
  @force_invalidate_snapshot = 1, 
  @force_reinit_subscription = 1;
GO

Uprawnienia

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