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
ASKER CERTIFIED SOLUTION
Avatar of lcohan
lcohan
Flag of Canada image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of holemania
holemania

ASKER

Thank you.
Microsoft SQL Server 2005
Microsoft SQL Server 2005

Microsoft SQL Server 2005 is a suite of relational database management system (RDBMS) products providing multi-user database access functionality.Component services include integration (SSIS), reporting (SSRS), analysis (SSAS), data quality, master data, T-SQL and performance tuning. It includes support for managing XML data and allows a database server to be exposed over web services using Tabular Data Stream (TDS) packets encapsulated within SOAP (protocol) requests.

72K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo