Trigger replication

Typically, remote databases have the same triggers defined as the consolidated database does.

By default, SQL Remote does not replicate the actions performed by the triggers. Instead, when an action that fires a trigger on the consolidated database is replicated on the remote database, the duplicate trigger is automatically fired on the remote database. This avoids permissions issues and the possibility of each action occurring twice. There are some exceptions to this rule:

  • Replication of RESOLVE UPDATE triggers   The actions carried out by conflict resolution, or RESOLVE UPDATE triggers are replicated from the consolidated database to all remote databases, including the remote database that sent the message that created the conflict.

  • Replication of BEFORE triggers   The actions of a BEFORE trigger that modifies a row being updated are replicated before the UPDATE statement actions.

    For example, a BEFORE UPDATE trigger that increases a counter column in the row to keep track of the number of times a row is updated would double count if replicated as the BEFORE UPDATE trigger fires on the remote database when the UPDATE statement is replicated.

    A BEFORE UPDATE trigger that sets a column to the time of the last update also receives the time the UPDATE statement is replicated.

    To prevent this problem, you must ensure that, at the subscriber database, the BEFORE UPDATE trigger is not present or does not perform the replicated action.

 An option to replicate trigger actions
 Avoiding trigger errors
 Extraction utility (dbxtract)
 See also