Merge replication does not allow ping-pong movement of data by design.
If you insert data into publisher, then your trigger fires and inserts
generated job number. Then it can be replicated without any problem because
the trafic in this case goes only from publisher to sybscribers.
If you insert data into synchronizer, then it is replicated to publisher.
There your trigger fires, generates new job number and inserts it into
publisher. Of course merge replication trigger is fired, but it skips
transfer of data back to subscriber, because it thinks that it the same data
that was transfered (from subscriber to publisher).
You should see following condition in the begining of every trigger of merge
replication:
if sessionproperty('replication_agent') = 1 and (select trigger_nestlevel())
= 1
This condition does the the checking which I described above.
Question is what could be done to workaround that... I would propose
modifying of the merge replication insert trigger on your jobs table in
publisher database. You could modify condition somehow that it would allow
execution of trigger when you need that.
For example something like that:
if ( sessionproperty('replication_agent') = 1 and (select
trigger_nestlevel()) = 1 ) OR ( sessionproperty('replication_agent') = 1 AND
UPDATE( job_nr_column_name ) )
Hope it helps.
--
Regards,
Kestutis Adomavicius
Consultant
UAB "Baltic Software Solutions"
[quoted text, click to view] "Me" <anonymous@discussions.microsoft.com> wrote in message
news:1c22901c45220$4427d9f0$a101280a@phx.gbl...
> Hi,
>
> I have a database that is replicated between 3 SQL servers
> at 3 different sites over a WAN link using merge
> replication.
>
> I want to use a trigger on a table to assign a sequential
> job number to records when one is needed. The trigger
> recognises certain conditions and determines if an updated
> row needs a job number. If it does, it updates the row
> with the job number.
>
> The job number given needs to be continuous amongst all
> the offices so the best way I could come up with to do
> this was to only put the trigger on 1 of the servers
> (server A). That way the next job number could be stored
> in a table and updated each time the trigger assigns one.
> I was hoping that when updates came from the other 2
> servers they would replicate to Server A, the trigger
> would fire and update the record, then the new job number
> would get replicated back to the other 2 servers. But that
> doesn't seem to be the case.
>
> Sometimes it works, but other times the records in Server
> A are the only ones that are updated. The changes never go
> back to the other servers so I end up with different data
> at each server.
>
> Has anyone got any ideas why this is happening? I'm
> completely stuck. I've searched all over the internet and
> can't find any help anywhere.
>
> Failing that, does anyone have any suggestions on better
> ways of doing this?
>
> Thank you for any help!