List all triggers in SQL Server

11

Is there a command that lists all triggers of a database in SQL Server?

    
asked by anonymous 01.09.2016 / 20:11

3 answers

12
SELECT * FROM sys.triggers

Documentation .

    
01.09.2016 / 20:14
3

Would that be what you are looking for?

SELECT Object_Name(parent_id) AS [Nome Objeto], 
       type_desc              AS Tipo, 
       modify_date            AS [Data Modificação] 
FROM   sys.triggers
    
01.09.2016 / 21:06
1

You can use the select below.

SELECT 
     sysobjects.name AS trigger_name 
    ,USER_NAME(sysobjects.uid) AS trigger_owner 
    ,s.name AS table_schema 
    ,OBJECT_NAME(parent_obj) AS table_name 
    ,OBJECTPROPERTY( id, 'ExecIsUpdateTrigger') AS isupdate 
    ,OBJECTPROPERTY( id, 'ExecIsDeleteTrigger') AS isdelete 
    ,OBJECTPROPERTY( id, 'ExecIsInsertTrigger') AS isinsert 
    ,OBJECTPROPERTY( id, 'ExecIsAfterTrigger') AS isafter 
    ,OBJECTPROPERTY( id, 'ExecIsInsteadOfTrigger') AS isinsteadof 
    ,OBJECTPROPERTY(id, 'ExecIsTriggerDisabled') AS [disabled] 
FROM sysobjects 
INNER JOIN sys.tables t 
    ON sysobjects.parent_obj = t.object_id     
INNER JOIN sys.schemas s 
    ON t.schema_id = s.schema_id 
WHERE sysobjects.type = 'TR' 

It returns in addition to the trigger name the table to use.

Documentation with trigger object select.

    
01.09.2016 / 20:39