How to find stored procedures by name?

巧了我就是萌 提交于 2019-12-23 10:07:21

问题


I just need to search through all the stored procedures on my database looking for one that contains "item" in its name. Any ideas?

I've been tinkering around with this, but it's not quite there yet:

SELECT DISTINCT OBJECT_NAME(ID) FROM SysComments WHERE Text LIKE '%Item%'

回答1:


To find those that contain the string "Item" in the name.

select schema_name(schema_id) as [schema], 
       name
from sys.procedures
where name like '%Item%'



回答2:


This can also help you on this issue. It also works when there are databases with different collations. And you can find procedure by passing either exact procedure name or part of its name.




回答3:


You can use new Query in Server 2008:

use dbName
go

print object_definition(object_id('storedProcedureName'))

You will get contents of procedure.




回答4:


With SQL, you can only use the % and _ wildcards. If you would like more powerful searching, you can use SchemaCrawler. SchemaCrawler can search for routines using regular expressions that match the name. You can even search within the routine definition using regular expressions.

Sualeh Fatehi, SchemaCrawler



来源:https://stackoverflow.com/questions/7338418/how-to-find-stored-procedures-by-name

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!