Specifying a Custom Resolver

SQL Replication

Replication

Specifying a Custom Resolver

A custom resolver can be specified from the Create Publication Wizard or with replication stored procedures.

Using the Create Publication Wizard

When a merge replication is created with the Create Publication Wizard, custom resolvers can be specified on the Specify Articles page. When a table is selected for publication, a properties (...) button is presented, which when clicked, displays the Properties dialog box for the article (table).

On the General tab, select whether changes to the same row or to the same column are regarded as conflicts. When changes to the same column are conflicts, changes to different columns in the same row are merged.

On the Resolver tab, select whether to use the default resolver, or a custom resolver, and then select one in the list. If the resolver references a specific column, enter its name in the Information for the custom resolver dialog box.

Using Replication Stored Procedures

When a merge replication is created with replication stored procedures, custom resolvers are specified from sp_addmergearticle or sp_changemergearticle.

In sp_addmergearticle, if a custom resolver is to be used, the resolver name from the table in the Microsoft Resolver Descriptions topic is entered with the @article_resolver parameter. The name must be typed exactly as it appears in the table. If a column name is required, it is entered with the @resolver_info parameter.

This example specifies that the Microsoft SQL Server Averaging Conflict Resolver be used with article ProductsArticle in publication ProductsPublication for source table Products to calculate the average of the UnitPrice column when conflicts occur.

exec @ret = sp_addmergearticle @publication='ProductsCatalog', 
            @article='ProductsArticle', @source_object='Products', 
            @article_resolver='Averaging Conflict Resolver', 
            @resolver_info='UnitPrice'

sp_changemergearticle is used to change one property of an existing merge article. The @property parameter specifies the property to be changed, the @value parameter specifies the new value for the property.

This example changes the article ProductsArticle in publication ProductsPublication to use the Microsoft SQL Server Additive Conflict Resolver to calculate the sum of the UnitsOnOrder column when conflicts occur.

exec @ret = sp_changemergearticle @publication='ProductsCatalog', 
            @article='ProductsArticle', @property='article_resolver', 
            @value='Additive Conflict Resolver'
exec @ret = sp_changemergearticle 
            @publication='ProductsCatalog', @article='ProductsArticle',
            @property='resolver_info', @value='UnitsOnOrder'

See Also

Microsoft Resolver Descriptions