Find stored procedure related to column in database in SQL Server

Here is quick query to find stored procedure related to column in database. This comes handy when you have to alter/remove a particular column from a table and you need to find all procedures referencing that column.

-- find stored procedure related to a column in database
SELECT DISTINCT objects.name, objects.type,
comments.text proc_defintion
FROM syscomments comments
INNER JOIN sys.objects objects 
ON comments.id=objects.object_id
WHERE comments.text LIKE '%AddressID%'
AND objects.type='P'

find stored procedure related to column in database

 
Like us on FaceBook  |  Join the fastest growing SQL Server group on FaceBook

Leave a Reply

Your email address will not be published. Required fields are marked *