簡體   English   中英

如何與 azure 數據工廠中的參數連接/在源查詢中傳遞動態表名

[英]how to concatenate with parameter in azure data factory / passing dynamic table names in source query

我已經在管道參數中創建,我想傳遞表數組來執行多個復制活動。 但在此之前,我只使用一個表作為參數進行測試。 我在表達式中創建了以下查詢(復制活動的接收器端)。 (請注意我正在從一個突觸復制到另一個突觸(從一個模式到另一個))

@concat('select * from DW_GL.',pipeline().parameters.p_param_input_table,' where updated_on >',activity('Old_Lookup1').output.firstRow.date_value,' and updated_on <=',activity('Old_Lookup1').output.firstRow.date_value_new)

我的表在模式“DW_GL”中,所以我試圖將它從上面的表達式中刪除,但它仍然無法正常工作。

我收到錯誤:

失敗發生在“來源”方面。 ErrorCode=SqlOperationFailed,'Type=Microsoft.DataTransfer.Common.Shared.HybridDeliveryException,Message=數據庫操作失敗,出現以下錯誤:'第 1 行的解析錯誤,第 75 列:'03' 附近的語法不正確。',Source =,''Type=System.Data.SqlClient.SqlException,Message=第 1 行的解析錯誤,第 75 列:'03' 附近的語法不正確。,Source=.Net SqlClient Data Provider,SqlErrorNumber=103010,Class=16 ,ErrorCode=-2146232060,State=1,Errors=[{Class=16,Number=103010,State=1,Message=第 1 行的解析錯誤,第 75 列:'03' 附近的語法不正確。,},] ,'

我嘗試從表達式中刪除空格。 還嘗試使用不連接的直接參數,因為 '@{pipeline().parameters.p_param_input_table}' 仍然無效。

我認為錯誤是因為此 concat 語句不包含日期值周圍的單引號 (')。 您需要使用 '' 來包含它們,轉換為 ''' 以結束(或開始)帶有 ' 的字符串,而 '''' 僅插入一個 ':

@concat('select * from DW_GL.',pipeline().parameters.p_param_input_table,' where updated_on > ''',activity('Old_Lookup1').output.firstRow.date_value,''' and updated_on <= ''',activity('Old_Lookup1').output.firstRow.date_value_new, '''')

下面的查詢也可以工作:

select * from DW_GL.@{pipeline().parameters.p_param_input_table} where updated_on > '@{activity('Old_Lookup1').output.firstRow.date_value}' and updated_on <=' @{activity('Old_Lookup1').output.firstRow.date_value_new}'

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM