Avatar of holemania
holemania
 asked on

SQL - Enable Trigger if Disabled, if enabled then disabled

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?
Microsoft SQL Server 2005SQL

Avatar of undefined
Last Comment
holemania

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
lcohan

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
holemania

ASKER
Thank you.
Your help has saved me hundreds of hours of internet surfing.
fblack61