[轉載]SQL Server查找包含某關鍵字的存儲過程3種方法

存儲過程都寫在一個指定的表中了,我們只要使用like查詢就可以實現查詢當前這臺SQL Server中所有存儲過程中包括了指定關鍵字的存儲過程並顯示出來,下面一起來看看我總結了幾條命令。

例子1

代碼如下

OBJECT_NAME(id),id from syscomments
where id in
( select object_id(name) from dbo.sysobjects where xtype='P'
)
and text like '%FieldName%'
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 '%key%' order by type_desc,name

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章