Consider the following scenario:
You configure a merge replication in Microsoft SQL Server 2008 or in Microsoft SQL Server 2008 R2.
The publication contains at least one table article.
The table article contains one or more DateTime2 columns.
You configure the article to use a custom businesslogic handler.
The businesslogic handler handles events that occur during merge replication synchronization.
The businesslogic handler uses a custom dataset to return the data.
The business logic handler resolves a conflict.
In this scenario, the merge agent may fail when it tries to store the conflict information. You may receive an error message that resembles the following:
The merge process could not store conflict information for article 'article_name'. Check the publication properties to determine where conflicts records are stored. When troubleshooting, restart the synchronization with verbose history logging and specify an output file to which to write. (Source: MSSQL_REPL, Error number: MSSQL_REPL-2147200992)
Error converting data type varchar to datetime2. (Source: MSSQLServer, Error number: 8114)
The Merge Agent encountered an error when executing code in the 'UpdateConflictsHandler' method implemented in the business logic handler 'C:\Resolver\BusinessLogicHandler_Sample.dll'. Ensure that the overridden 'UpdateConflictsHandler' method has been properly implemented in the business logic handler. (Source: MSSQL_REPL, Error number: MSSQL_REPL-2147199411)
This issue occurs because the DateTime2 values are stored in a variable of data type string when data is passed between managed code and unmanaged code.
Note The SQL Server merge agent is written in unmanaged code. The business logic for the Microsoft .NET assembly is written in managed code.
Microsoft has confirmed that this is a bug in the Microsoft products that are listed in the "Applies to" section.
You may be able to work around this issue by storing the DateTime2 values in a column that has one of the following data types
For example, the issue that is described in the "Symptoms" section occurs if the custom business logic handles conflicting UPDATE statements at the publisher and the subscriber. The DateTime2 values are converted into a variable of data type string when the data is passed between the managed code and the unmanaged code. The data of data type string resembles the following:
2 0 1 5 - 1 2 - 3 1 1 2 : 3 4 : 5 6 . 7 8 9 0 0 0 0
However, the stored procedure that handles the conflict metadata for the article expects the data to be of data type DateTime2. Therefore, the issue that is described in the "Symptoms" section occurs.
This issue occurs if the data is not changed in custom code that resembles the following code sample.
public override ActionOnUpdateConflict UpdateConflictsHandler(..., ref customDataSet, ...)
customDataSet = publisherDataSet.Copy();
conflictLogType = ConflictLogType.ConflictLogPublisher;
For more information about how to implement a business logic handler for a merge article, visit the following MSDN website:
http://msdn.microsoft.com/en-us/library/ms147911.aspx For information about issues that can occur when you store values in DateTime columns, see the following article in the Microsoft Knowledge Base:
2598510 DateTime values are rounded to the nearest second when a business logic handler is used in SQL Server 2008 or SQL Server 2008 R2