Solved

Temporarily disable all triggers on a SQL Server DB

Posted on 2010-09-17
2
778 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
2 Comments
 
LVL 11

Accepted Solution

by:
aelliso3 earned 500 total points
Comment Utility
--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
Comment Utility
Perfect!
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

After restoring a Microsoft SQL Server database (.bak) from backup or attaching .mdf file, you may run into "Error '15023' User or role already exists in the current database" when you use the "User Mapping" SQL Management Studio functionality to al…
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

743 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now