January 12, 2022 08:08 by
Peter
This is a query which will help to retrieve all the tables and functions used in a store procedure, even if the query is a dynamic one.
SELECT objects.name As suspected_dependencies
FROM sys.procedures
INNER
JOIN sys.all_sql_modules
ON all_sql_modules.object_id = procedures.object_id
LEFT
JOIN sys.objects
ON objects.name <> procedures.name
AND all_sql_modules.definition LIKE '%' + objects.name + '%'
WHERE procedures.name = <Procedure Name>
Output
HostForLIFEASP.NET SQL Server 2019 Hosting