Quantcast
Channel: SQL Server Integration Services forum
Viewing all articles
Browse latest Browse all 24688

Using System::StartTime in variable for external file name comes out incorrect sometimes

$
0
0

Hi All,

I have an interesting dilemma.  I'm using SQL Server 2005 with Visual Studios 2005 (9.00.4035.00).

I'm writing records from my database table out to an external flat file, nothing fancy other than in the naming of the file being dynamic and using system time.  So I have a couple of variables set:

CR_Dir = \\host\directory\

CR_Outfile = "AP_" +  (DT_WSTR, 4)  YEAR( @[System::StartTime] ) + RIGHT("0" + (DT_WSTR, 2) MONTH(@[System::StartTime] ),2) + RIGHT("0" + (DT_WSTR,2) DAY( @[System::StartTime] ),2) + RIGHT("0"+ (DT_WSTR,2) DATEPART("Hh", @[System::StartTime] ), 2) + RIGHT("0" + (DT_WSTR,2) DATEPART("mi", @[System::StartTime] ),2) + RIGHT("0" + (DT_WSTR,2) DATEPART("ss", @[System::StartTime] ),2)+ "_chref"

And then in my Connection Manager properties I have an expression that brings them all together with a file extension:

@[User::CR_Dir] +  @[User::CR_Outfile] + ".ctl"

So what I should get for example is something like AP_20140309214502_chref.ctl  (if the job was run on 03/09/2014 @ 9:45pm) When executed properly.  I do this for two flat files one with an extension of .txt and the other with .ctl.  These steps are working fine the majority of the time.

However, my problem is that occasionally, the portion of the filename that contains the datetime stamp is completely incorrect for one of the two files that are created during the same time frame.  And I'm not talking about a few seconds or even a minute or two, the date is off by weeks.  Here's an example:

AP_20140309214502_chref.txt

AP_20140213152253_chref.ctl

This has happened twice since starting to run this job over the past four months, once on 12/15/2013 and again 03/09/2014.  This job is run every night at 9:45pm, and all the other days that this job runs the two filenames come out perfectly.  So I'm leaning towards something in the system that may be corrupting my variable every once in a while?  But because it happens intermittently how can I verify this?  Or is there a better way to perform what I'm trying to do that would be more accurate and consistent?

Any help would be appreciated.

Thanks


Sawyer


Viewing all articles
Browse latest Browse all 24688

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>