Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the list of active triggers on a database?

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
like image 263
LaBracca Avatar asked Mar 09 '12 12:03

LaBracca


People also ask

How can I see all triggers in database?

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.

Which command Return list of triggers?

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.

How do I get a list of active sessions in SQL Server?

In SQL Server Management Studio, right click on Server, choose "Activity Monitor" from context menu -or- use keyboard shortcut Ctrl + Alt + A .


1 Answers

SELECT *
FROM sys.triggers
WHERE is_disabled = 0
like image 89
Lamak Avatar answered Oct 23 '22 07:10

Lamak