如何在SQL Server中搜索到一个带有某关键字的存储过程?
反向工程中, 这一招很实用. 如果是研发人员, 就直接去源代码控制工具中去搜索了.
经过测试, 下面的任何一条查询都可以满足题目的需求.
SELECT Name FROM sys.procedures WHERE OBJECT_DEFINITION(object_id) LIKE '%foobar%'
SELECT OBJECT_NAME(object_id) FROM sys.sql_modules WHERE Definition LIKE '%foobar%' AND OBJECTPROPERTY(object_id, 'IsProcedure') = 1
SELECT ROUTINE_NAME, ROUTINE_DEFINITION FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_DEFINITION LIKE '%foobar%' AND ROUTINE_TYPE='PROCEDURE'
资料来源:
How do I find a stored procedure containing <text>?
http://databases.aspfaq.com/database/how-do-i-find-a-stored-procedure-containing-text.html