How to get list of all Triggers with table name in MS-SQL



Which trigger belongs to wich table and schema can be queried as -


To get all triggers name with table names :
select t.name as TriggerName, tbl.name as OnTable 
from sys.triggers t
inner join sys.tables tbl
ON t.parent_id = tbl.object_id


To get all non-active (disabled) triggers name with table names :
select t.name as TriggerName, tbl.name as OnTable 
from sys.triggers t
inner join sys.tables tbl
ON t.parent_id = tbl.object_id
where t.is_disabled=1


To get all triggers with table name, and Schema name :
select t.name as TriggerName, tbl.name as OnTable, sc.name as SchemaName
from sys.triggers t
inner join sys.tables tbl
ON t.parent_id = tbl.object_id
inner join sys.schemas sc
ON sc.schema_id= tbl.schema_id

Ebook Download
View all
Learn
View all