How to Disable All Constraints in the Database temporarily in SQL Server ?

There are times when you may want to disable all the constraints in the your SQL Server Database tables when importing the data from the external data source .

How to Disable All Constraints in the Database temporarily in SQL Server ?

Below is a sample query that lets you to quickly disable the constraints like foreign keys , unique keys etc for the database tables.

EXEC sp_msforeachtable "ALTER TABLE ? NOCHECK CONSTRAINT all"

Simple isn’t it ?