How to: Disable Foreign Key Constraints for Replication (Visual Database Tools)

In SQL Server 2005, if a table is published using replication, foreign key constraints are automatically disabled for operations performed by replication agents. When a replication agent performs an insert, update, or delete at a Subscriber, the constraint is not checked; if a user performs an insert, update, or delete, the constraint is checked. The constraint is disabled for the replication agent because the constraint was already checked at the Publisher when the data was originally inserted, updated, or deleted. For more information, see Controlling Constraints, Identities, and Triggers with NOT FOR REPLICATION.

You can also explicitly disable foreign key constraints for replication, which can be useful if you are publishing data from a previous version of SQL Server.

To disable a foreign key constraint for replication

  1. In Object Explorer, expand the table with the foreign key constraint you want to modify, and then expand the Keys folder.

  2. Right-click the foreign key constraint and then click Design (Modify in SP1 or earlier).

  3. In the Foreign Key Relationships dialog box, select a value of No for Enforce For Replication.

  4. Click Close.

See Also

Concepts

FOREIGN KEY Constraints

Other Resources

Working with Constraints (Visual Database Tools)
Working with Relationships (Visual Database Tools)

Help and Information

Getting SQL Server 2005 Assistance