Solved

Temporarily disable all triggers on a SQL Server DB

Posted on 2010-09-17
2
812 Views
Last Modified: 2012-05-10
I need to disable all triggers temporarily on a SQL Server DB (2008) so I can run some insert scripts against it.   How can I do this with one statement?   I don't really feel like going through each individual trigger on 65 tables and disabling them.  Also, I need to know how to re-enable them when the scripts are done.   Thanks.
0
Comment
Question by:saturation
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 11

Accepted Solution

by:
aelliso3 earned 500 total points
ID: 33704780
--Disable all triggers
EXEC sp_MSforeachtable @command1="ALTER TABLE ? DISABLE TRIGGER ALL"

 
--Enable all triggers
EXEC sp_MSforeachtable @command1="ALTER TABLE ? ENABLE TRIGGER ALL"  
 
0
 

Author Closing Comment

by:saturation
ID: 33705164
Perfect!
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Long way back, we had to take help from third party tools in order to encrypt and decrypt data.  Gradually Microsoft understood the need for this feature and started to implement it by building functionality into SQL Server. Finally, with SQL 2008, …
If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question