My application is based on a sql server db.
All customers has the same db except for customizations.
Some customizations include: new tables, modified tables, custom views, custom triggers...
When I run the software update some scripts are executed. Now I manually disable triggers and reenable after the scripts are done.
Anyway I would like automatically to disable all the triggers (that are enabled, may be some of them could be already disabled) and then reenable them at the end.
Not to reinvent the whell, how to do that?
How to get only the active triggers on the current db?
Once I got this I can programmatically create and run the
DISABLE TRIGGER triggername ON TABLENAME
ENABLE TRIGGER triggername ON TABLENAME
To view database level triggers, Login to the server using SQL Server management studio and navigate to the database. Expand the database and navigate to Programmability -> Database Triggers. To view triggers at the server level, Login to Server using SSMS and navigate to Server Objects and then Triggers folder.
SHOW TRIGGERS lists the triggers currently defined for tables in a database (the default database unless a FROM clause is given). This statement returns results only for databases and tables for which you have the TRIGGER privilege.
In SQL Server Management Studio, right click on Server, choose "Activity Monitor" from context menu -or- use keyboard shortcut Ctrl + Alt + A .
SELECT *
FROM sys.triggers
WHERE is_disabled = 0
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With