SQL Server查找包含某关键字的存储过程3种方法

作者:袖梨 2022-06-29

例子1

 代码如下 复制代码

select OBJECT_NAME(id),id from syscomments
where id in
( select object_id(name) from dbo.sysobjects where xtype='P'
)
and text like '%FieldName%'
group by id

例子2

数据库SQL Server 2005/2008中,查询包含某关键字的存储过程语句:

 代码如下 复制代码

select distinct b.name
from dbo.syscomments a, dbo.sysobjects b
where a.id=b.id  and b.xtype='p' and a.text like '%text%'
order by name

例子3

关键字查找相关的存储过程、触发器、函数和视图

 代码如下 复制代码

select name,type_desc from sys.all_sql_modules s inner join sys.all_objects o on s.object_id=o.object_id where definition like '%keyword%' order by type_desc,name

相关文章

精彩推荐