You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Control behavior of triggers & constraints in synchronization
description
Learn how to prevent triggers from executing or constraints from being enforced during the synchronization of a SQL Server Replication Publication.
author
MashaMSFT
ms.author
mathoma
ms.date
09/25/2024
ms.service
sql
ms.subservice
replication
ms.topic
how-to
ms.custom
updatefrequency5
helpviewer_keywords
identities [SQL Server replication]
constraints [SQL Server], replication
triggers [SQL Server], replication
triggers [SQL Server replication]
constraints [SQL Server replication]
NOT FOR REPLICATION option
NFR option
dev_langs
TSQL
monikerRange
=azuresqldb-mi-current||>=sql-server-2016
Control Behavior of Triggers and Constraints in Synchronization
[!INCLUDE SQL Server SQL MI]
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
To prevent constraints from being enforced during synchronization
When creating a new CHECK or FOREIGN KEY constraint, specify CHECK NOT FOR REPLICATION option in the constraint definition of CREATE TABLE (Transact-SQL).