Search

Wednesday, November 16, 2011

Disable All Constraints or Triggers in a Single Command


--Disable Constraints 
EXEC sp_MSforeachtable 'ALTER TABLE ? NOCHECK CONSTRAINT ALL' 
--Disable Triggers 
EXEC sp_MSforeachtable 'ALTER TABLE ? DISABLE TRIGGER ALL' 
-- Load data Now

--Enable Constraints 
EXEC sp_MSforeachtable 'ALTER TABLE ? CHECK CONSTRAINT ALL' 
--Enable Triggers 
EXEC sp_MSforeachtable 'ALTER TABLE ? ENABLE TRIGGER ALL' 

No comments:

Post a Comment