Using a Custom Resolver

Microsoft® SQL Server™ comes with five sample custom resolvers to help you implement custom resolvers in your application. The five samples include a:

Custom Stored Procedure Resolver

This sample application builds a custom stored procedure resolver that executes the stored procedure at the Publisher. The resolver uses a distributed query to get information from the Subscriber and computes the average price if the values are different. If any columns other than price have changed, the resolver uses the values from the Publisher. It then makes the average price the resolved value and logs the conflict at the Publisher so it can be viewed and, if necessary, changed. Finally, the application finds the Vice-President of Sales and sends him e-mail stating that the price was changed to an average due to a conflict. The sample code is located in the \Mssql7\Devtools\Samples\Sqlrepl\Deflt_sp. directory. The resolver is designed to run on the Products table in Northwind sample database. The file Avgprice.sql contains both the sample code and directions for implementing sp_avgprice.

Publisher-based Resolver

This sample application builds a custom stored procedure resolver that executes the stored procedures at the Publisher. It contains a sample script to set up a publication in Northwind and install the sample resolver on the Products article. The stored procedure that is used to resolve the conflicts returns the “Average Unit Price” if both the Publisher and Subscriber made conflicting changes to the UnitPrice column in the Products table. The sample C++ code is located int he \Mssql7\Devtools\Samples\Sqlrepl\Resolver\Pubspres directory. The directory also includes a Readme.txt file that provides additional information about the resolver.

Subscriber-based Resolver

This sample application builds a custom stored procedure resolver that executes the stored procedure at the Subscriber. It contains a sample script to set up a publication on pubdb and install the sample resolver that calls sp_authority_resolver. sp_authority_resolver retrieves the ‘authority’ value from the table at Publisher and Subscriber, and the row with the highest authority will ‘win’ and be returned to the merge process to be applied to both servers.  If both rows have the same authority, the source table will win. The sample C++ code is located in the \Mssql7\Devtools\Samples\Sqlrepl\Resolver\Subspres directory. The directory also includes a Readme.txt file that provides additional information about the resolver.

datetime-based Resolver

This is a sample custom resolver application for the sales article in the sample merge publication created by Instsamp.sql. It is a datetime-based resolver that use the ord_date column in the sales table. It resolves conflicts by ensuring that the most recent update based on ord_date always wins. Sample C++ code to build the resolver is located in the \Mssql7\Devtools\Samples\Sqlrepl\Resolver\DateTime directory. The directory also includes a Readme.txt file that provides additional information about the resolver.

Merge Text Resolver

The merge text resolver can be used for applications where there is a text column that is updated by appending additional comments. For example, the resolver could be used with the Notes column of the Employees table in the Northwind sample database. The resolver behaves simlarly to the default priority-based resolver, except when conflicting updates have been applied to a text column. In this case, the default resolver would choose a winner and log a conflict row with the losing values. The merge text resolver merges the two text values in the following way: If both text values share a common initial substring, the result is one value followed by a separator and then the unique part of the second value (that is, everything following the initial substring). This is useful for applications that append to text columns, as both things that are appended will be preserved.

The merge text resolver behaves like the default resolver except in cases where conflicting updates have been made to a text column. In this case, the resolver merges the values. By concatenating (common substring) + (rest of value1)  + (separator) + (rest of value2).

This resolver is not appropriate for applications where the updates to the text columns are not appends because the values would be concatenated, although no conflicts would be logged. The sample C++ code is located in the \Mssql7\Devtools\Samples\Sqlrepl\Resolver\Mergetxt directory. The directory also includes a readme.txt file that provides additional information about the resolver.

See Also
Priority-based Conflict Resolution Custom Stored Procedure Conflict Resolver
Reporting and Resolving Conflicts  

  


(c) 1988-98 Microsoft Corporation. All Rights Reserved.