在某些特殊场景下,不得不用到触发器,触发器是置入到数据表内,维护不方便,下面的查询语句能快速查询到所有的触发器分布在哪些表中,方便维护。

select triggers.name as [触发器],tables.name as [表名],triggers.is_disabled as [是否禁用],
triggers.is_instead_of_trigger AS [触发器类型],
case when triggers.is_instead_of_trigger = 1 then ‘INSTEAD OF’
when triggers.is_instead_of_trigger = 0 then ‘AFTER’
else null
end as [触发器类型描述]
from sys.triggers triggers
inner join sys.tables tables on triggers.parent_id = tables.object_id
where triggers.type =’TR’
order by triggers.create_date

下面是查询存储过程的
select name,id,crdate,refdate from sysobjects where xtype=’P’;–存储过程
select name,id,crdate,refdate from sysobjects where xtype=’V’;–视图
select name,id,crdate,refdate from sysobjects where xtype=’U’;–表

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。