Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 SSIS and Import/Export (2005)
 How to modify SSIS variable in script task

Author  Topic 

SQLIsTheDevil
Posting Yak Master

177 Posts

Posted - 2011-02-02 : 17:15:56
Hello,

I couldn't think of a proper title without running over the limit of the Subject field. I have an SSIS package with a number of variables. Each of these variables' values are particular SQL statements. But what is common among all the SQL Statements is they contain two dates, both fixed, i.e. Select * from table where date>'01/01/2010' and date<'02/01/2010'. What I want to do is make both dates variables inside the SSIS variable, i.e. Select * from table where date > @startdate and date < @enddate.

I know how to pass in a SSIS variable to a Script Task, but is there some way I can use Script Task to just manipulate the date fields inside the SSIS variable?

The whole point of this exercise is the dates will change every month for these queries and I want some way to automate the process. For the record, I'm using VB.NET.

dataguru1971
Master Smack Fu Yak Hacker

1464 Posts

Posted - 2011-02-02 : 17:55:10
You need to have two more variables one for each date. The variable is a string, so it won't "See" the variables if you change the dates to variables there.

You can build the whole string in a script task by using the two new date variables and populate the SQL query variable with the result...




Poor planning on your part does not constitute an emergency on my part.
Go to Top of Page

SSISJoost
Starting Member

9 Posts

Posted - 2011-02-07 : 15:32:00
Using variables in a Script Task:
http://microsoft-ssis.blogspot.com/2010/12/how-to-use-variables-in-script-task.html
Go to Top of Page
   

- Advertisement -