troubleshooting Question

SQL - Enable Trigger if Disabled, if enabled then disabled

Avatar of holemania
holemania asked on
Microsoft SQL Server 2005SQL
2 Comments1 Solution454 ViewsLast Modified:
I have about 6 triggers that are disabled.  I need to enable whenever I do some sort of security changes to the application.  Instead of enabling/disabling the trigger one by one, I need help with one script to check the status of these 6 triggers.  

I want to disabled the 6 triggers if it's in enabled state, and enabled all 6 if it's on disabled state.

I did a query to see which triggers is disabled and which one enabled, but not sure how I can incorporate this into my sql script.

SELECT NAME, IS_DISABLED FROM SYS.TRIGGERS

Triggers are:
Update_User
Insert_User
Delete_User
Update_Permission
Insert_Permission
Delete_Permission

So I want to create a stored procedure that when execute, will check status.  If it's disabled (Is_Disabled = 1), then enable it.  If it's enable (Is_Disabled = 0) then disabled it.  Also return the current status of the 6 triggers after running the stored procedure. Any thoughts?
ASKER CERTIFIED SOLUTION
lcohan
Database Analyst

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros