Export (0) Print
Expand All

Disable Check Constraints for Replication

You can disable check constraints in SQL Server 2014 by using SQL Server Management Studio or Transact-SQL. You can also explicitly disable check constraints for replication, which can be useful if you are publishing data from a previous version of SQL Server.

Note Note

If a table is published using replication, check 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 Specify Schema Options.

In This Topic

Security

Permissions

Requires ALTER permission on the table.

Arrow icon used with Back to Top link [Top]

To disable a check constraint for replication

  1. In Object Explorer, expand the table with the check constraint you want to modify, and then expand the Constraints folder.

  2. Right-click the check constraint you wish to modify and then click Modify.

  3. In the Check Constraints dialog box, under Table Designer, select a value of No for Enforce For Replication.

  4. Click Close.

Arrow icon used with Back to Top link [Top]

To disable a check constraint for replication

  1. In Object Explorer, connect to an instance of Database Engine.

  2. On the Standard bar, click New Query.

  3. Copy and paste the following example into the query window and click Execute. The example creates a table with an IDENTITY column and a CHECK constraint on the table. The example then drops the constraint and recreates it specifying the NOT FOR REPLICATION clause.

    USE AdventureWorks2012;
    GO
    CREATE TABLE dbo.doc_exd (column_a int IDENTITY (1,1) 
    CONSTRAINT exd_check CHECK (column_a > 1)) 
    
    ALTER TABLE dbo.doc_exd 
    DROP CONSTRAINT exd_check; 
    GO
    ALTER TABLE dbo.doc_exd  
    ADD CONSTRAINT exd_check CHECK NOT FOR REPLICATION (column_a > 1);
    

For more information, see ALTER TABLE (Transact-SQL).

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft