如何将变量传递给 SSIS 中 ODBC 源的 sql 查询? [英] How to pass variable to sql query of ODBC Source in SSIS?
问题描述
我在 SSIS 的数据流任务中使用 ODBC 源.我只想从 ODBC 源中选择最新数据,
I am using ODBC source in Data flow task of SSIS. I want to select only latest data from ODBC source,
这是我的查询:
从 ODBCTable 中选择 *其中日期 >= @[user::date1]
Select * from ODBCTable where date >= @[user::date1]
但是我在解析查询时出错.
But i am getting error while parsing query.
这是什么替代方式?我如何传递变量以及如何创建有效变量来传递只能给我最新的今天日期数据的查询.
What is the alternative way this? How can i pass the variable and how to create effective variable to pass the query that can give me only latest today's date data.
感谢高级版.
推荐答案
在 SQL 命令文本中,首先声明您的变量,然后编写您的 sql 语句:
In the SQL Command text, first declare your variable then write your sql statement:
declare @user_date1 date = cast(? as date)
Select * from ODBCTable where date >= @user_date1
然后单击参数"按钮以将 SSIS 参数值映射到您的 sql 变量.映射是按照 SQL 命令中出现的顺序完成的 - 而不是按名称.
Then click on the Parameters button to map an SSIS parameter value to your sql variable. The mapping is done in order of appearance in your SQL Command - not by name.
这篇关于如何将变量传递给 SSIS 中 ODBC 源的 sql 查询?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!