Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Query to find out the stored procedure depending on a column

I have to change the name and the datatype of a column of a table. I have about 150 stored procedures in the database, out of which about 25 refer to the same column. I need a query that can find the name of all the stored procedures which are dependent on this column.

like image 413
Vaibhav Jain Avatar asked Dec 07 '25 08:12

Vaibhav Jain


1 Answers

I use this query:

SELECT OBJECT_NAME(M.object_id), M.*
FROM sys.sql_modules M
JOIN sys.procedures P
ON M.object_id = P.object_id
WHERE M.definition LIKE '%blah%'

Obviously you'd have to substitute "blah" for the name of your column.

like image 145
DigCamara Avatar answered Dec 08 '25 20:12

DigCamara