?
Solved

Temporarily disable all triggers on a SQL Server DB

Posted on 2010-09-17
2
Medium Priority
?
828 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 2000 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

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

I have written a PowerShell script to "walk" the security structure of each SQL instance to find:         Each Login (Windows or SQL)             * Its Server Roles             * Every database to which the login is mapped             * The associated "Database User" for this …
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…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

762 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