List all triggers in SQL Server

Asked

Viewed 15,156 times

15

Is there any command, that lists all the triggers from a database in SQL Server?

3 answers

18


4

That’s what you’re looking for?

SELECT Object_Name(parent_id) AS [Nome Objeto], 
       type_desc              AS Tipo, 
       modify_date            AS [Data Modificação] 
FROM   sys.triggers

2

You can use 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 beyond the Trigger name the table to use.

Documentation with select of the Trigger object.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.