3

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.

Jan Schultke
  • 17,446
  • 6
  • 47
  • 96
Jack
  • 510
  • 3
  • 6
  • 22

2 Answers2

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

gofr1
  • 15,741
  • 11
  • 42
  • 52
Aashish Jain
  • 121
  • 5
2

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.

tember
  • 1,418
  • 13
  • 32