Hi @kkran ,
Happy New Year!
Please refer below query and check whether it is helpful to you.
use [databasename]
go
SELECT DB_NAME() AS DatabaseName,
d1.referenced_entity_name TableName,
d1.referenced_schema_name SchemaName,
case when o1.type ='P' then 'StoredProcedure'
when o1.type ='TF' then 'Function'
when o1.type ='V' then 'View' end Type ,
OBJECT_NAME(d1.referencing_id) Name
FROM sys.sql_expression_dependencies d1
JOIN sys.objects o
ON d1.referenced_id = o.[object_id]
JOIN sys.objects p
on OBJECT_NAME(d1.referencing_id)=p.name
join sys.objects o1
on OBJECT_NAME(d1.referencing_id)=o1.name
where o.type_desc ='USER_TABLE'
and o1.type in ('P','TF','V')
order by DB_NAME() ,referenced_schema_name,referenced_entity_name
If you would like to get SQL Server Cross database Dependencies, you could also refer this forum.
Best regards
Melissa
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.