T-SQL script to list object dependencies
-- SQL Server 2008 object dependency query - listing object dependencies
SELECT ReferencingObjectType = o1.type,
ReferencingObject = SCHEMA_NAME(o1.schema_id)+'.'+ o1.name,
ReferencedObject = SCHEMA_NAME(o2.schema_id)+'.'+ ed.referenced_entity_name,
ReferencedObjectType = o2.type
FROM sys.sql_expression_ dependencies ed
INNER JOIN sys.objects o1
ON ed.referencing_id = o1.object_id
INNER JOIN sys.objects o2
ON ed.referenced_id = o2.object_id
WHERE o1.type in ('P','TR','V', 'TF')
ORDER BY ReferencingObjectType, ReferencingObject
No comments:
Post a Comment