How to disable Foreign Key constraints using T-SQL in SQL Server ?

Published on August 25, 2016 by abundantcode

Filed under SQL Server

Last modified August 25, 2016

Print this page

rate 1 star rate 2 star rate 3 star rate 4 star rate 5 star
Your rating: none, Average: 0 (0 votes)

This article have been viewed 4455 times

You can enable or disable the foreign key constraints for a table in a SQL Server using the ALTER statement.

How to disable Foreign Key constraints using T-SQL in SQL Server ?

Here’s the T-SQL query to disable all the constraints of the table "Employee".

ALTER TABLE HumanResources.Employee NOCHECK CONSTRAINT ALL

If you want to enable all the constraints of the table , here’s how you do it.

ALTER TABLE HumanResources.Employee WITH CHECK CHECK CONSTRAINT ALL

Leave a Comment


x

You might be Interested in these Posts

How to Perform Inner Join using LINQ in C# ?

Are you looking for the syntax on how to perform inner join using LINQ in C# ? . Below is a sample c...

C Program to a print pascal triangle

Problem Statement Write a program in C to print pascal triangle. How to print a pascal triange in ...

C Program to delete an element from an array

Problem Statement Write a program in C to delete an element from an array. How to delete an elemen...