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.

6
  • I have defined variable but how can i use ? insted of @[user::date1], how to map these. Commented Dec 30, 2015 at 11:35
  • if variable is define then use ? like where date >= ? Commented Dec 30, 2015 at 11:36
  • But my variable name is date1, then how i map date1 to ?. Commented Dec 30, 2015 at 11:38
  • where you define the variable there is one mapping tab within that map the variable and with your where clause variable and put question mark after equal sign Commented Dec 30, 2015 at 11:41
  • 3
    Possible duplicate of SSIS ODBC SQL parameters Commented Dec 30, 2015 at 14:19

2 Answers 2

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.

Sign up to request clarification or add additional context in comments.

Comments

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.