[英]Find All the tables related to a stored procedure in Azure Synapse Datawarehouse
Is there a simple way to find out all the tables referenced in a stored procedure in azure analytics data warehouse other than parsing the stored procedure code? azure分析数据仓库中的存储过程中引用的所有表,除了解析存储过程代码外,有没有简单的方法? I tried few commands like sp_tables , sp_depends but none seems to be working in azure data warehouse.
我尝试了一些命令,如sp_tables 、 sp_depends但似乎没有一个在 azure 数据仓库中工作。
sys.sql_expression_dependencies is supported in Azure Synapse Analytics, dedicated SQL pools, but only supports tables, views and functions at this time. Azure Synapse Analytics 支持 sys.sql_expression_dependencies,专用 SQL 池,但目前仅支持表、视图和函数。 A simple example:
一个简单的例子:
SELECT * FROM sys.sql_expression_dependencies;
So you are left either parsing sys.sql_modules
.所以你要么解析
sys.sql_modules
。 Something like this is imperfect (ie doesn't deal with schema name, square brackets, partial matches etc) but could server as a starting point:这样的事情是不完美的(即不处理模式名称、方括号、部分匹配等)但可以作为起点:
SELECT
sm.[definition],
OBJECT_SCHEMA_NAME(t.object_id) schemaName,
OBJECT_NAME(t.object_id) tableName
FROM sys.sql_modules sm
CROSS JOIN sys.tables t
WHERE sm.object_id = OBJECT_ID('dbo.usp_test')
AND sm.[definition] Like '%' + t.name + '%';
I actually use SQL Server Data Tools (SSDT) with dedicated SQL pools so your dependencies can't get out of step and are trackable via the project.实际上,我将 SQL 服务器数据工具 (SSDT) 与专用的 SQL 池一起使用,这样您的依赖项就不会失调,并且可以通过项目进行跟踪。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.