I need to find all views & stored procedures that consume not just a certain table, but a specific column in a table.
The following "seems" to work, but there are numerous warnings to be careful with this method (not reliable for a variety of reasons, soon to be deprecated, etc):
SELECT object_name(so.id) TableName, sc.name ColumnName, OBJECT_NAME(sd.id) DependentObjectName, (SELECT xtype FROM sysobjects so WHERE so.id = sd.id) Object_Type FROM sysobjects so INNER JOIN syscolumns sc ON so.id = sc.id INNER JOIN sysdepends sd ON so.id = sd.depid and sc.colid = sd.depnumber WHERE object_name(so.id) = 'MyTableName' AND sc.name = 'MyColumnName' order by object_name(so.id), Object_Type
Some alternative approaches that are often referenced are sys.sql_dependencies and sys.sql_expression_dependencies, but neither of these have column level granularity.
Does anyone know a way of doing this? (Or even if you know definitively that it literally cannot be done, it would be helpful to know.)