查找插入到特定表中的存储过程 [英] Find Stored Procedure that Inserts Into a Specific Table
问题描述
是否可以找到在表中创建条目的存储过程。例如,
Is there a way to find what stored procedures create an entry in a table. Say for example:
存储过程A插入表A
存储过程B插入表A
存储过程C插入表B
Stored Procedure A inserts into Table A
Stored Proceudre B Inserts into Table A
Stored Procedure C Inserts into Table B
我要查询返回存储过程A和存储过程B的名称。
I want to the query to return the name of Stored Procedure A and Stored Procedure B.
我现在已经知道了,但所做的只是找到存储过程。我认为这将是找到存储过程的一个很好的起点。
Ive got this right now, but all it does is find Stored Procedures. I think it would be a good starting point to find the stored procedures.
select schema_name(schema_id) as [schema],
name
from sys.procedures
where name like '%Item%' and name like '%Create%'
我正在使用Microsoft SQL 2008
I am using Microsoft SQL 2008
推荐答案
您可以搜索 sys.sql_modules
,其中包含所有proc和视图的文本:
You can search sys.sql_modules
which contains the text of all the procs and views:
SELECT OBJECT_NAME(object_id)
FROM sys.sql_modules
WHERE definition LIKE '%TablenameIWanttoFind%'
如果您能确定措辞,可以搜索类似'INSERT INTO mytable'
If you are certain of the wording you can search for something like 'INSERT INTO mytable'
这篇关于查找插入到特定表中的存储过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!