How to pass variable to sql query of ODBC Source in SSIS?

怎甘沉沦 提交于 2021-01-29 03:16:17

问题


I am using ODBC source in Data flow task of SSIS. I want to select only latest data from ODBC source,

Here is my query:

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.

Thanks in Advanced.


回答1:


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

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.




回答2:


You can do in this way create one variable query then form your query there with parameter . enter image description here

enter image description here

then goto dataflow properties , in expression select ODBC source.sqlcoomand and pass that variable here.

On first run will replace source query with the expression sql command. Thanks



来源:https://stackoverflow.com/questions/34528412/how-to-pass-variable-to-sql-query-of-odbc-source-in-ssis

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!