

NOCHECK CONSTRAINT FK_PurchaseOrderHeader_Employee_EmployeeID USE AdventureWorks2012 ĪLTER TABLE Purchasing.PurchaseOrderHeader In Object Explorer, connect to an instance of Database Engine.Ĭopy and paste the following example into the query window and select Execute.
Sqlitestudio foreign key to same table update#
Use Transact-SQL To disable a foreign key constraint for INSERT and UPDATE statements To check whether foreign keys are trusted in your database, see a sample query later in this article. Trusted foreign keys are recommended because they can be used to simplify execution plans with assumptions based on the foreign key constraint. The query optimizer is therefore unable to consider potential performance improvements.

To re-enable the constraint when desired, reverse the above steps. In the grid under Table Designer, select Enforce Foreign Key Constraint and select No from the drop-down menu. Right-click the constraint and select Modify. In Object Explorer, expand the table with the constraint and then expand the Keys folder. Use SQL Server Management Studio To disable a foreign key constraint for INSERT and UPDATE statements Limitations and restrictionsĪfter you disable these constraints, future inserts or updates to the column will not be validated against the constraint conditions. Use this option if you know that new data will not violate the existing constraint or if the constraint applies only to the data already in the database. You can disable a foreign key constraint during INSERT and UPDATE transactions in SQL Server by using SQL Server Management Studio or Transact-SQL.
