How to: Control the Behavior of Triggers and Constraints During Synchronization (Replication Transact-SQL Programming)

更新日期: 2006 年 4 月 14 日

During synchronization, replication agents execute INSERT (Transact-SQL), UPDATE (Transact-SQL), and DELETE (Transact-SQL) statements on replicated tables, which can cause data manipulation language (DML) triggers on these tables to be executed. There are cases when you may need to prevent these triggers from firing or constraints from being enforced during synchronization. This behavior depends on how the trigger or constraint is created.

To prevent triggers from executing during synchronization

  1. When creating a new trigger, specify the NOT FOR REPLICATION option of CREATE TRIGGER (Transact-SQL).

  2. For an existing trigger, specify the NOT FOR REPLICATION option of ALTER TRIGGER (Transact-SQL).

To prevent constraints from being enforced during synchronization

  1. When creating a new CHECK or FOREIGN KEY constraint, specify CHECK NOT FOR REPLICATION option in the constraint definition of CREATE TABLE (Transact-SQL).

请参阅

其他资源

创建和修改表
使用 NOT FOR REPLICATION 来控制约束、标识和触发器

帮助和信息

获取 SQL Server 2005 帮助