sp_addmergefilter

Transact-SQL Reference

Transact-SQL Reference

sp_addmergefilter

Adds a new merge filter to create a partition based on a join with another table. This stored procedure is executed at the Publisher on the publication database.

Syntax

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 ]

Arguments

[@publication = ] 'publication'

Is the name of the publication that contains the article. publication is sysname, with no default.

[@article = ] 'article'

Is the name of the article. article is sysname, with no default.

[@filtername = ] 'filtername'

Is the name of the filter. filtername is a required parameter. filtername is sysname, with no default.

[@join_articlename = ] 'join_articlename'

Is the article name of the join table. join_articlename is sysname, with no default. The article must be in the publication given by publication.

[@join_filterclause = ] join_filterclause

Is the filter clause qualifying the join. join_ filterclause is nvarchar(2000). join_filterclause defines only Boolean filters in this stored procedure.

[@join_unique_key = ] join_unique_key

Specifies if the join is on a unique key in the table specified in @article. join_unique_key is int, with a default of 0. 0 indicates a nonunique key. 1 indicates a unique key in @join_articlename.

[@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 specifies that changes to the merge article will not cause the snapshot to be invalid. If the stored procedure detects that the change does require a new snapshot, and error will occur and no changes will be made. 1 specifies that changes to the merge article may cause the snapshot to be invalid, and if there are existing subscriptions that would require a new snapshot, gives permission for the existing snapshot to be marked as obsolete and a new snapshot generated.

[@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 specifies that changes to the merge article will not cause the subscription to be reinitialized. If the stored procedure detects that the change would require subscriptions to be reinitialized, an error will occur and no changes will be made. 1 specifies that changes to the merge article will cause existing subscriptions to be reinitialized, and gives permission for the subscription reinitialization to occur.

Return Code Values

0 (success) or 1 (failure)

Remarks

sp_addmergefilter is used in merge replication.

Typically, this option is used for an article that has a foreign key reference to a published primary key table, and the primary key table has a filter defined in its article. The subset of primary key rows is used to determine the foreign key rows that are replicated to the Subscriber.

Permissions

Only members of the sysadmin fixed server role or db_owner fixed database role can execute sp_ addmergefilter.

See Also

sp_changemergefilter

sp_dropmergefilter

sp_helpmergefilter

System Stored Procedures