Quantcast
Viewing latest article 17
Browse Latest Browse All 24688

Keeping Dynamic DateTime Variable "Static"

In one step of an SSIS package, i create an outgoing XLS filename based on the current datetime setting, a la:

 

"myFileName_" + (DT_WSTR,4)YEAR( getdate()) + RIGHT("0" + (DT_WSTR,2)MONTH( getdate()),2)+
RIGHT("0" + (DT_WSTR,2)DAY( getdate()),2) +
RIGHT("0" + (DT_WSTR,2)DATEPART("hh", getdate()),2) +
RIGHT("0" + (DT_WSTR,2)DATEPART("mi", getdate()),2) +
RIGHT("0" + (DT_WSTR,2)DATEPART("ss", getdate()),2) +".xls"

 

which provides the format as myFileName_yyyymmddhhmmss.xls.

 

This value is then assigned to a variable, user::myFilenameDateTime.

 

This variable is referred to in various steps which need the full pathname or filename.

 

I found, though, that in subsequent steps, the value for user::myFilenameDateTime is re-calculated whenever the variable is invoked.

 

So in one Task i created the physical output XLS file and named it "correctly", eg, myFileName_20070428090204.xls; in the next Task, i call a Stored Procedure in SQL Server 2005 to email the file with a corresponding message (that pulls in more data from the database).

 

The single Parameter to the Stored Procedure (that does the emailing) is the supposed/expected full Pathname of the outgoing file just produced but the parameter no longer represents the original filename -- and has changed slightly (a few seconds have been added) and the filename is now, myFileName_20070428090210.xls; consequently, my Email Distribution program cannot find the file with that specific name, although File = myFilename_20070428090204.xls does certainly exist.

 

so it appears that these variables are calculated realtime whenever encountered.

 

1) Am I misunderstanding something or misusing the variable assignment?

2) How can i keep << myFileName_yyyymmddhhmmss.xls >>, "static" throughout the duration of the overal SSIS Process.

3) I would think that even if I assign the derived myFileName value initially to ANOTHER "static" variable, this won't achieve anything because the new variable will be re-calculated again, as well, when it is invoked.

 

thx/spirits,

 

seth j hersh

 

 

 


Viewing latest article 17
Browse Latest Browse All 24688

Trending Articles