Schema: How do I show all the triggers in a database?
The following code uses a pair of nested recordsets to grab the triggers from the sysobjects table and then display them using sp_helptext (tested in SQL Server 2000):
Note that you must loop through the sp_helptext resultset because, as with stored procedures, each line of code in a trigger is returned as one row in the resultset.
Are there other ways to do this? Sure, here's some sample code, but it should be avoided due to its reliance on an undocumented SP (as well as the fact that it produces a resultset for every table, regardless of whether it has a trigger):
And this code, adapted from a post by Alejandro Mesa - which includes more information, but not the text for each trigger in the current DB:
Related ArticlesSchema: How do I list all the indexes in a database?
Schema: How do I list the databases on my server?
Schema: How do I show all the primary keys in a database?
Schema: How do I show the columns for a table?
Schema: How do I show the description property of a column?
Schema: How do I show the parameters for a function or stored procedure?
Schema: How do I show the stored procedures in a database?
Schema: How do I show the tables in a database?
Schema: How do I show the user-defined functions (UDFs) in a database?
Schema: How do I show the views in a SQL Server database?