问题
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 .
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