How to: Disable Foreign Key Constraints for Replication

If you publish a table by using replication, you automatically disable foreign key constraints for operations that replication agents perform. The constraint is still checked when a user performs an insert, update, or delete operation but not when a replication agent performs one at a Subscriber. 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" on the Microsoft Web site.

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.


The dialog boxes and menu commands you see might differ from those described in Help depending on your active settings or edition. To change your settings, choose Import and Export Settings on the Tools menu. For more information, see Visual Studio Settings.

To disable a foreign key constraint for replication

  1. In Server Explorer, select the table with the constraint, and from the Database menu click Open Table Definition.

    The table opens in Table Designer.

  2. From the Table Designer menu, click Relationships.

  3. In the Foreign Key Relationships dialog box, select the relationship in the Selected Relationship list.

  4. In the grid, click Enforce For Replication, and in the box to the right choose No from the drop-down list box.

See Also


Foreign Keys (Visual Database Tools)

Other Resources

Working with Constraints

Working with Relationships