Need to list all triggers in SQL Server database with table name and table's schema

后端 未结 19 924
再見小時候
再見小時候 2020-11-28 17:12

I need to list all triggers in SQL Server database with table name and table\'s schema.

I\'m almost there with this:

SELECT trigger_name = name, trig         


        
19条回答
  •  無奈伤痛
    2020-11-28 18:05

    SELECT
       ServerName   = @@servername,
       DatabaseName = db_name(),
       SchemaName   = isnull( s.name, '' ),
       TableName    = isnull( o.name, 'DDL Trigger' ),
       TriggerName  = t.name, 
       Defininion   = object_definition( t.object_id )
    
    FROM sys.triggers t
       LEFT JOIN sys.all_objects o
          ON t.parent_id = o.object_id
       LEFT JOIN sys.schemas s
          ON s.schema_id = o.schema_id
    ORDER BY 
       SchemaName,
       TableName,
       TriggerName
    

提交回复
热议问题