List of all Stored Procedures having particular string or text or column name in SQL Server

Search Stored Procedure for Column Name

Question: I want to find the stored procedures list which are updating a column of a Table.

Answer:

SELECT obj.Name SPName, sc.TEXT SPText

FROM sys.syscomments sc

INNER JOIN sys.objects obj ON sc.Id = obj.OBJECT_ID

WHERE sc.TEXT LIKE '%' + 'Your Coulmna name/text' + '%'

AND TYPE = 'P'

 

1) Search in All Objects like Tables, Stored Procedures, views etc.,

-- Search in All Objects

SELECT OBJECT_NAME(OBJECT_ID),

definition

FROM sys.sql_modules

WHERE definition LIKE '%' + 'Your Column name/text' + '%'

 

 2) Search in Stored Procedure

-- Search in Stored Procedure Only

SELECT DISTINCT OBJECT_NAME(OBJECT_ID),

object_definition(OBJECT_ID)

FROM sys.Procedures

WHERE object_definition(OBJECT_ID) LIKE '%' + 'Your Column name/text' + '%'