Find all stored procedures that reference a specific column in some table Find all stored procedures that reference a specific column in some table sql-server sql-server

Find all stored procedures that reference a specific column in some table


One option is to create a script file.

Right click on the database -> Tasks -> Generate Scripts

Then you can select all the stored procedures and generate the script with all the sps. So you can find the reference from there.

Or

-- Search in All ObjectsSELECT OBJECT_NAME(OBJECT_ID),definitionFROM sys.sql_modulesWHERE definition LIKE '%' + 'CreatedDate' + '%'GO-- Search in Stored Procedure OnlySELECT DISTINCT OBJECT_NAME(OBJECT_ID),object_definition(OBJECT_ID)FROM sys.ProceduresWHERE object_definition(OBJECT_ID) LIKE '%' + 'CreatedDate' + '%'GO

Source SQL SERVER – Find Column Used in Stored Procedure – Search Stored Procedure for Column Name


If you want to get stored procedures using specific column only, you can use try this query:

SELECT DISTINCT NameFROM sys.ProceduresWHERE object_definition(OBJECT_ID) LIKE '%CreatedDate%';

If you want to get stored procedures using specific column of table, you can use below query :

SELECT DISTINCT Name FROM sys.proceduresWHERE OBJECT_DEFINITION(OBJECT_ID) LIKE '%tbl_name%'AND OBJECT_DEFINITION(OBJECT_ID) LIKE '%CreatedDate%';


You can use ApexSQL Search, it's a free SSMS and Visual Studio add-in and it can list all objects that reference a specific table column. It can also find data stored in tables and views. You can easily filter the results to show a specific database object type that references the column

enter image description here

Disclaimer: I work for ApexSQL as a Support Engineer