Groups | Blog | Home
all groups > sql server replication > november 2003 >

sql server replication : Adding column in merge


Antonio Iglesias
11/20/2003 2:20:16 PM
I have defined a merge replication scenario since both subscriber and
publisher need to update data. I have a table that has a numeric field
that, if there is a conflict, I want to add up.

I have defined this article to use "Additive Conflict Resolver", but somehow
it does not work as I expect.

The desired behaviour is as follows:
1. If the numeric field starts as 0, and I update both the subscriber and
publisher to 1, when they sync I want to end up with 2: [ 0 + (1-0) + (1-0)
= 2].
2. If the numeric field starts as 0, and I update one of them to 2 and the
other to 3, I want to end up with 5: [ 0 + (2-0) + (3-0) = 5].
3. If the numeric field starts as 5, and I update one of them to 2 and the
other to 4, I want to end up with 1: [ 5 + (2-5) + (4-5) = 1].

What really happens:
1. If there is no conflict (the values are the same on both, even after
changing), nothing occurs, so in the first case I am getting a 1 in the
field instead of the 2 I would like.
2. If I update both and the value is different then it does sum up the
values (works as I would like).
3. But if I decrease the values (in which case I would like it to decrease
by the difference) it goes back to the previous value. :-(

This table is one in a group of many that are working perfectly well with
merge replication.

What would be the way to go? Any ideas?


Regards.

Antonio.

v-yshao NO[at]SPAM online.microsoft.com
11/21/2003 9:10:54 AM
Hi Antonio,

Thanks for your post. As I understand, you define the article in merge
replication using "Additive Conflict Resolver". According to your
description, I think the actions you got are the normal actions of the
merge replication with "Additive Conflict Resolver".
When we use "Additive Conflict Resolver" to handle update conflict,
conflict winner determined from priority value. Specified column values set
to sum of source and destination column values. If one is set to NULL, they
are set to the value of the other column.

I also performed some tests on my side. The numeric field starts as 0.
After updating both the subscriber and publisher to 1, the result is 1.
Because there is no conflict occurring. After updating one of them to 2 and
the other to 3, the result is 5. Because the conflict occurred, the
Specified column values is 5 (2+3).

Please feel free to post in the group if this solves your problem or if you
would like further assistance.

Regards,

Michael Shao
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
Antonio Iglesias
11/24/2003 1:35:04 PM
Hi Michael,

This is the behavior I was seeing, but it is not the desired behavior.
I have switched to transactional replication and I am modifying the
procedures created by SQLServer to take into account our needs.
Is this the way to go? Should I avoid modifying these procedures?

Regards,

Antonio.

"Michael Shao [MSFT]" <v-yshao@online.microsoft.com> escribió en el mensaje
news:7SpIX9AsDHA.3428@cpmsftngxa07.phx.gbl...
[quoted text, click to view]

v-yshao NO[at]SPAM online.microsoft.com
11/25/2003 9:50:52 AM
Hi Antonio,

Thanks for your feedback. In my previous post, I would like to say that
when we choose "Additive Conflict Resolver" as the conflict resolver, the
actions what you saw is normal. I would like to know what the procedures
provided by SQL Server you indicated. Can you describe them in detail?

Also, you can use Transact-SQL to build your custom conflict resolver as a
stored procedure at each Publisher. Custom conflict resolvers are always
executed at the Publisher. For more information regarding Custom Stored
Procedure Conflict Resolver, please refer to the following article on SQL
Server Books Online.
Topic: "Custom Stored Procedure Conflict Resolver"

Thanks for using MSDN newsgroup.

Regards,

Michael Shao
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

AddThis Social Bookmark Button