Variable/Expressions in an SSIS Package

  • I'm hoping someone can lead me in the right direction. I need to pull 6 weeks of data starting with the current week back. I created a view that provides me with the parameters and I created an SSIS package that pulls the data. How can I create an expression or variables that can be passed to the data flow task. If I hard code the variables I can get what I need but I want to supply them dynamically. The database I pull from is a large DB2 database and I want to be able to pass the keys for the begin date and end date. For instance between 2009121 and 2010013. I have these parameters in the view. If I manually change the variables every week it works but I want to define the variables based on the view. Is this possible?

  • You could set up an Execute SQL task that runs prior to the data flow that gets the start/end date values and populates package level variables.

    Just curious, why not just use date logic in your source query inside your data flow?

    John Rowan

    ======================================================
    ======================================================
    Forum Etiquette: How to post data/code on a forum to get the best help[/url] - by Jeff Moden

  • If I used date logic I would have to bring in the time dimension table from the source. This is not recommended because of the size of the database. I pull at least a million records per week per source.

  • Well, like I said, use an ExecuteSQL task prior to your Data Flow. Have that task query get your start/end date parameters and place them inside package variables.

    Here's a great article on using the ExecuteSQL task that should answer any questions you have on using them to populate variables.

    http://www.sqlis.com/post/The-Execute-SQL-Task.aspx

    John Rowan

    ======================================================
    ======================================================
    Forum Etiquette: How to post data/code on a forum to get the best help[/url] - by Jeff Moden

  • Thanks John, this will work.

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply