Sunday, July 14, 2013

Find all Stored Procedure names which uses a certain column name

Have you ever gone through a situation where, one of your table columns getting updated without you knowing and you need to find which SP does this !!!

Here's the easiest way to find all the references or SP names which uses the table column name that your worried about.

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 '%' + '<Column Name>' + '%'
AND TYPE = 'P'

The result will be as follows,