Hi,
We need to generate csv file with datetime (to milli seconds) to distinguish from other files. I am setting up a variable like this at package scope:
variable @[user::RepFilePath]
"C:\\Backup\\ABC\\" + "REP_HLDS_" + (DT_WSTR,4)YEAR(GETDATE())
+ RIGHT("0" + (DT_WSTR,2)MONTH(GETDATE()), 2)
+ RIGHT("0" + (DT_WSTR,2)DAY(GETDATE()), 2)
+"T"
+ (DT_WSTR,2) DATEPART( "hh", GETDATE() )
+ (DT_WSTR,2) DATEPART( "mi", GETDATE() )
+ (DT_WSTR,2) DATEPART( "ss", GETDATE() )
+ (DT_WSTR,3) DATEPART( "Ms", GETDATE() )
+ ".csv"
In dataflow task, getting data from sql server and using flat file destination, generating CSV file using above variable as file name. There is another process that copies the files from above folder. Once data is retrieved from sql server, need to
do conditional split and generate 3 files. Some times there may be data that satifies for only 2 files or 1 file. In that case rest of the empty files are getting generated even though there are no rows.
After doing lot of research, using rowcount transformation task to get row count in DataFlow and after execution comes back to control flow, trying to delete a generated file using File System Task. For delete, I am using @[user::RepFilePath] as source
variable. When I run the package, it shows that it ran successfully, but I still I see a file in the folder. How does this dynamic file name generation variable work.
Does it get set once when package starts running and stays same throughout until it is changed again or it gets builts dynamically when ever variable is accessed ? As far as I know, if scope is set to package, it is available to all tasks in the package,
but value changes when ever it is accessed because it is set as expression.
Please clarify and let me know how to handle this.
Thanks