CREATE TABLE DependencyTest
(ID INT,
Col1 VARCHAR(10)
)
GO
CREATE PROCEDURE usp_test
AS
BEGIN
CREATE TABLE #temp(tID INT, tCol1 VARCHAR(10))
INSERT INTO #temp(tID, tCol1)
SELECT ID, Col1
FROM DependencyTest
DROP TABLE #temp
END
GO
SELECT referenced_minor_name,referencing_schema_name+'.'+referencing_entity_name
FROM sys.dm_sql_referencing_entities('dbo.DependencyTest', 'object')
CROSS APPLY sys.dm_sql_referenced_entities(referencing_schema_name+'.'+referencing_entity_name,'object')
WHERE referenced_minor_name IN ('Col1')
If i run the DMV query, usp_test is not listed in the result-set even though the columns are referenced inside this SP. Any explanation about this behavior?