您的当前位置:首页正文

SQL Server 查询哪些存储过程、触发器 中用到了指定表

2024-11-07 来源:个人技术集锦
--查询哪些存储过程中用到了指定表
SELECT DISTINCT
	b.name,
	b.type
FROM	dbo.syscomments a,
		dbo.sysobjects b
WHERE a.id = b.id
AND b.xtype = 'p'
AND a.text LIKE '%表名%'
ORDER BY name
--查询所有出发器
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   c.text like '%ORDER_EXE_SPLIT_RULE%'
ORDER BY [表名]
显示全文