Is there a way to find what stored procedures create an entry in a table. Say for example:
Stored Procedure A inserts into Table A
Stored Proceudre B Inserts into Table A
Stored Procedure C Inserts into Table 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%'
I am using Microsoft SQL 2008
6条答案
按热度按时间xghobddn1#
You can search
sys.sql_modules
which contains the text of all the procs and views:If you are certain of the wording you can search for something like
'INSERT INTO mytable'
1szpjjfi2#
The question asks how to find a stored procedure that inserts into a specific table.
Searching for stored procedures containing the name may bring back quite a few false positives if the table is referenced for many selects.
sys.sql_dependencies
is deprecated but can be useful here as it contains anis_updated
flag that also is set to1
for inserts.ma8fv8wu3#
Why don't you use the below query.
From this query you can literally find anything procedure with a specific text in it.
eufgjt7s4#
I needed to know what the actual object id is, i.e. Stored Procedure / Trigger, etc.
So thanks to JNK, I altered the script to show it to me like this:
Results show like this:
gj3fmq9x5#
List's top 10 stored procedure executed that do insert/update on a table by last execution time you can you use below script
mv1qrgav6#