mssql sqlserver 查询一张数据表下触发器信息


摘要:
下文讲述使用sql脚本的方式查询一张数据表下的触发器信息,如下所示:
实验环境:sql server 2008 R2


例:
获取数据表”maomao365″下的触发器信息,如下所示:

   SELECT
object_name(a.parent_obj) as [表]
,a.name as [触发器]
,(case when b.is_disabled=0 then ‘使用中’ else ‘停用’ end) as [触发器状态]
,b.create_date as [写入日期]
,b.modify_date as [最后修改日期]
,c.text as [触发器内容]
FROM sysobjects a
INNER JOIN sys.triggers b
ON b.object_id=a.id
INNER JOIN syscomments c
ON c.id=a.id
WHERE a.xtype=’tr’ ——tr代表类型 触发器 
   and object_name(a.parent_obj) ='maomao365'      ----maomao365数据表名称