[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 848
  • Last Modified:

Temporarily disable all triggers on a SQL Server DB

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
saturation
Asked:
saturation
1 Solution
 
aelliso3Commented:
--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
 
saturationAuthor Commented:
Perfect!
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now