Storing formatted Datetime stamp in variable
I would create a Script Task as a first step in the package and use System::StartTime to get the package start time, then format the file name variable right in there using VB or C# (if you are on SSIS 2008) because you are familiar with it, I would use the resulting value down the road in the step where you create the files. PS: This article gives some more details: http://www.thejoyofcode.com/SSIS_Custom_Logging_Task_for_Event_Handlers.aspxArthur My Blog
February 8th, 2011 5:10pm

You have noted down all thats required. Where are you getting stuck?My Blog | Ask Me
Free Windows Admin Tool Kit Click here and download it now
February 8th, 2011 5:20pm

I'm writing three flay files and use the connection string to create the filename for the flat file "C:\\CLM OUTPUT\\TEST_PRODUCT_CONTROL_FILE_" + (DT_WSTR, 4) YEAR( GETDATE()) + RIGHT( "0" + (DT_WSTR, 2) MONTH( GETDATE()), 2 ) + RIGHT("0" + (DT_WSTR, 2) DAY( GETDATE() ), 2 ) + REPLACE((DT_WSTR, 30)(DT_DBtime) GETDATE(), ":", "") + ".txt" I produce three files all with a slightly different timestamp but usually within the same minute. Anyway the client thinks they want all three files to have the same timestamp so I figured I'd capture the pkg start timestamp and place it in the variable. Then in the connectionstrings for the flatfiles use that same timestamp to make each of the three files by using the variable in the connection string to the flat file connections. What's the best way to do this in SSIS. I'm a .NET programmer of 11 years but this interface I'm still learning..... Basically I need to (DT_WSTR, 4) YEAR( GETDATE()) + RIGHT( "0" + (DT_WSTR, 2) MONTH( GETDATE()), 2 ) + RIGHT("0" + (DT_WSTR, 2) DAY( GETDATE() ), 2 ) + REPLACE((DT_WSTR, 30)(DT_DBtime) GETDATE(), ":", "") to produce a string that looks like this 20110207153606 and place that in a variable and then use it in the flatfile connection string like "C:\\CLM OUTPUT\\TEST_PRODUCT_CONTROL_FILE_" + [VARIABLE] + ".txt" Where do I start?
February 8th, 2011 7:03pm

I got it thanks!! Created a variable named TimeStamp and set the expression to replacing GetDate() with the System variable ContainerStartTime: (DT_WSTR, 4) YEAR( @[System::ContainerStartTime]) + RIGHT( "0" + (DT_WSTR, 2) MONTH( @[System::ContainerStartTime]), 2 ) + RIGHT("0" + (DT_WSTR, 2) DAY( @[System::ContainerStartTime]), 2 ) + REPLACE((DT_WSTR, 30)(DT_DBtime) @[System::ContainerStartTime], ":", "") Make sure you set the EvaluateAsExpression to True in the variable's properties!! Next I went back into each of the flatfile connection string expressions and replace what I had to get the actual time stamp and replaced it with my variable "C:\\CLM OUTPUT\\TEST_PRODUCT_CONTROL_FILE_" + @TimeStamp + ".txt"
Free Windows Admin Tool Kit Click here and download it now
February 8th, 2011 7:03pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics