SQLUSA

Microsoft SQL Server 2005 Best Practices

How to disable all triggers and constraints?

 

Execute the following script in Query Editor to disable all triggers and constraints. Warning: data captured is not validated anymore. Prior to turning them back on, data has to be verified.

USE AdventureWorks;

EXEC sp_MSforeachtable @command1="ALTER TABLE ? DISABLE TRIGGER ALL"

EXEC sp_MSforeachtable @command1="ALTER TABLE ? NOCHECK CONSTRAINT ALL"


 

The Best SQL Server 2005 Training in the World
 
 
SQLUSA.com Home Page