映射数据流 SQL 查询和参数失败

Mapping data flow SQL query and Parameters failing

在我的映射数据流中,我已将其简化为 dimdate 仅用于测试

我的参数是

源代码甚至告诉你如何输入 select 查询如果你正在使用我正在努力实现的参数

然后我导入但得到两个不同的错误 用于参数化 table`

SELECT * FROM {$df_TableName}

我明白了

This error from a select * or invidiual columns

我只尝试将 WHERE 子句(我实际需要的)作为参数,但一直收到数据类型不匹配错误

然后我开始测试多种方式,它只允许从下面的查询中参数化模式

无论我做什么,所有这些其他选项似乎都失败了

SELECT * FROM [{$df_Schema}].[{$df_TableName}] Where [Period] = {$df_incomingPeriod}

SELECT * FROM [dbo].[DimDate] Where [Period] = {$df_incomingPeriod}

SELECT * FROM [dbo].[{$df_TableName}] Where [Period] = {$df_incomingPeriod}

SELECT * FROM [dbo].[DimDate] Where [Period] = 2106

我知道 Integer 数据类型存在问题,但不知道如何在不更改其类型的情况下将其传递给参数内的查询,因为 sql 引擎无法 运行 [period]作为字符串

在表达式构建器中使用 CONCAT 函数在 Dataflow 中构建查询。

concat(<this> : string, <that> : string, ...) => string

Note: Concatenates a variable number of strings together. All the variables should be in form of strings.

示例 1:

concat(toString("select * from "), toString($df_tablename))

示例 2:

concat(toString("select * from "), toString($df_tablename), ' ', toString(" where incomingperiod = "), toString($df_incomingPeriod))

太棒了,它对我来说就像魔法一样奏效。我正在努力参数化 tables= names 我正在通过 Array 列表。 创建了一个数据流参数并赋予了这个值: @item().TABLE_NAME