Viewing DDL Trigger Metadata by joining sys.triggers and sys.sql_modules : sys.triggers « System Tables Views « SQL Server / T-SQL Tutorial






4>
5> SELECT t.name, m.Definition
6> FROM sys.triggers AS t
7> INNER JOIN sys.sql_modules m ON
8> t.object_id = m.object_id
9> WHERE t.parent_class_desc = 'DATABASE'
10> GO
name
         Definition


------------------------------------------------------------------------------------------------------------------------
-------- ---------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------
-------------------------
db_trg

CREATE TRIGGER db_trg
ON DATABASE
FOR CREATE_INDEX, ALTER_INDEX, DROP_INDEX
AS
SET NOCOUNT ON
INSERT dbo.MyAudit
(EventData, DBUser)
VALUES (EVENTDATA(), USER)








27.19.sys.triggers
27.19.1.Viewing DDL Trigger Metadata by querying sys.triggers
27.19.2.Viewing DML Trigger Metadata: Show the DML triggers in the current database
27.19.3.Viewing DDL Trigger Metadata by joining sys.triggers and sys.sql_modules