How to generate a merge conflict in a trigger ?

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Hello,

I would like to be able to generate a conflict for merge replication inside
a trigger.

The problem appears in some tables like 'Customers' where the primary key is
an IDENTITY where in the replication is automatically managed by SQL Server
2000 without any problem. But the application that uses this database uses a
CFI (customer friendly identification) in conjunction with a column that
makes it active or not (for the application), because we cannot delete data
(invoices, etc..) for legal stuff.
But I cannot have two CFI actives.


So I can have in the table the following information:
ID CFI Name Active
2 J2 Johan 0
3 A4 Michel 1
4 J2 Joe 1

But I cannot add:
5 J2 Joanne 1


And I've a TRIGGER to avoid that (although the application still controls
that). But in the replication, there's no conflict but I get this error (I
have translated it, so it might not appear exactly the same in your English
version):

The process cannot give the updates to 'Publisher'.
(Source: Provider of merge replication (Agent); Error number: -2147200989)
---------------------------------------------------------------------------------------------------------------
This error is RAISED by the trigger. You are trying to have two "customer
friendly identification" actives
(Source: INDRA\SQLSERVER2000 (Data source); Error number: 50000)
---------------------------------------------------------------------------------------------------------------

In this case I've made the changes to the Subscriber and is the publisher
that fires the trigger. But the same happens if I make the change in the
Publisher.

That makes the agent fail and I don't get any conflict to resolve (that's
what I would like). So can I generate a conflict in the trigger or there are
other ways to solve this kind of problems?


Thank you for your help,

Josep Martínez







.



Relevant Pages

  • Re: Complicated Merge Replication/Trigger problem
    ... tracking Im going to cause a conflict as far as I understand it? ... After making the changes on the publisher ... and 1 upload is showing in replication monitor. ... Curiously when I disabled the trigger and made the ...
    (microsoft.public.sqlserver.replication)
  • Re: Replication conflict
    ... I think the trigger should look like this ... FOR INSERT, UPDATE NOT FOR REPLICATION ... is removing the domain name, whereas this will perform better for you. ... between sync's you will have a conflict. ...
    (microsoft.public.sqlserver.replication)
  • Re: Replication conflict
    ... First off I think your trigger is incorrect. ... It is only good for singleton ... FOR INSERT, UPDATE NOT FOR REPLICATION ... between sync's you will have a conflict. ...
    (microsoft.public.sqlserver.replication)
  • Re: Replication conflict
    ... I made the change to the trigger, but I am still having conflicts. ... Looking for a SQL Server replication book? ... The data into this table is added by an end user at the Publisher. ... between sync's you will have a conflict. ...
    (microsoft.public.sqlserver.replication)
  • Re: Triggers and Merge replication
    ... Merge replication does not allow ping-pong movement of data by design. ... If you insert data into publisher, then your trigger fires and inserts ... > I have a database that is replicated between 3 SQL servers ...
    (microsoft.public.sqlserver.replication)