Server Version: SQL Server 2008R2 Client Version: SQL Server Express 2008R2
I have been encountering what appears to be locking issues when I run my merge replication process. It appears to be when a change is made on the subscriber and sync'd with the publisher. I am posi开发者_如何学Gotive is coming from the triggers because it is appearing that they are firing on the publisher again and probably trying to send data down to the subscribers again. I have added "NOT FOR REPLICATION" to the triggers, but that doesn't seem to be helping. I also researched and tried adding the below clause as well.
DECLARE @is_mergeagent BIT
SELECT @is_mergeagent = convert(BIT, sessionproperty('replication_agent'))
IF @is_mergeagent = 0 --IF NOT FROM REPLICATION
That didn't seem to help either. How do you handle Merge Replication with Insert / Update triggers? Can I prevent them from "Double" firing?
Always appreciate the info.
--S
Not sure about triggers firing but SESSIONPROPERTY will give NULL here. So the subsequent test always fails.
<Any other string>
[gives] NULL = Input is not valid.
You probably mean APP_NAME
This should at least assist troubleshooting...
i'd add a bit field to the table that's causing the issue and call it "processed" or something like that. have it default to false and then set to true when the trigger updates that record, and have the trigger check for a false value before it does anything, otherwise have it do nothing.
精彩评论