繁体   English   中英

在 Azure 数据工厂预复制脚本中截断表?

[英]Truncating tables in Azure Data Factory Pre-Copy script?

我正在构建一个管道,现在我需要截断 azure sql db 中的目标表,但在此之前我需要截断目标表。 但我无法弄清楚脚本:

点击查看 SINK 设置的 ADF 截图

相反,我输入了这段代码,但这是错误的,因为它在表的每个副本之前运行(5 次)并截断除最后一个之外的所有表。 所以我需要让它参数化我猜:

*truncate table [dbo].[Global_data.csv]
truncate table [dbo].[Option_data.csv]
truncate table [dbo].[State_data.csv]
truncate table [dbo].[Status_data.csv]
truncate table [dbo].[Target_data.csv]*

另请参阅我的源参数:

**ADLSv2 container: @pipeline().parameters.SourceContainer
ADLSv2 Directory: @pipeline().parameters.SourceDirectory
ADLSv2 filename:  @item().name
Sink TableName:   @item().name**

所以我猜我的预脚本必须是这样的: truncate table @item().name但这对我来说是一个错误:

错误截图

DetailsErrorCode= SqlOperationFailed,'Type=Microsoft.DataTransfer.Common.Shared.HybridDeliveryException,Message=A database operation failed with the following error: 'Incorrect syntax near '@item'.',Source=,''Type=System.Data.SqlClient.SqlException,Message=Incorrect syntax near '@item'.,Source=.Net SqlClient Data Provider,SqlErrorNumber=102,Class=15,ErrorCode=-2146232060,State=1,Errors=[{Class=15,Number=102,State=1,Message=Incorrect syntax near '@item'.,},],'

当我使用TRUNCATE TABLE [@{item()}]时,我得到以下错误 5 次(相应地每个表一个):

ErrorCode=SqlOperationFailed,'Type=Microsoft.DataTransfer.Common.Shared.HybridDeliveryException,Message=A database operation failed with the following error: 'Cannot find the object "{"name":"StateMetadata.csv","type":"File"}" because it does not exist or you do not have permissions.',Source=,''Type=System.Data.SqlClient.SqlException,Message=Cannot find the object "{"name":"StateMetadata.csv","type":"File"}" because it does not exist or you do not have permissions.,Source=.Net SqlClient Data Provider,SqlErrorNumber=4701,Class=16,ErrorCode=-2146232060,State=1,Errors=[{Class=16,Number=4701,State=1,Message=Cannot find the object "{"name":"StateMetadata.csv","type":"File"}" because it does not exist or you do not have permissions.,},],'

请使用截断表 TRUNCATE TABLE [@{item().name}]

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM