SQL to search stored procedures if a specific table and column are used.
select OBJECT_NAME( sd.[object_id] ) As ObjectName, OBJECT_NAME( ac.[object_id] ) As DependentTableName
, ac.[Name] As DependentColumnName
from sys.sql_dependencies sd
JOIN sys.all_columns ac ON sd.[referenced_major_id] = ac.[object_id]
AND sd.[referenced_minor_id] = ac.[column_id]
JOIN sys.objects so ON sd.[object_id] = so.[object_id]
WHERE so.[type] = 'P'
AND OBJECT_NAME( ac.[object_id] ) = 'tablename' --Tablename
AND ac.name = 'field' -- column name
Written by Michael Griffith
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Sql
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#