Wednesday, July 3, 2013

Set the dynamic date in variable of SSIS

Suppose if you need to create dynamic file which contains the file name with current date and time associated with it  in SSIS,then you have to follow below steps:

1>Define a variable ‘FilePath’ and set its value as null.
   


 
 



  Then  select the Filepath variable and go to property section on right side.

 
Then Set the EvaluateAsExpression As ‘TRUE’ and open the wizard in expression part by clicking on  

 



And under expression part set the value like “Filepath”+"ddmmyy"-"hhmm".txt

For ex:  "C:\\Documents and Settings\\mshukla\\Desktop\\Country\\EmpDetails"+ "_" + (dt_str,4,1252)datepart("yyyy", @[System::StartTime]) + "_" + right("0" + (dt_str,4,1252)datepart("mm", @[System::StartTime]),2) + "_" + right("0" + (dt_str,4,1252)datepart("dd", @[System::StartTime]),2)+"_"+".txt"
 
 

 


  Then go to the FlatFileConnection Manager and select property by right click on it.

Select Expression and then click on
 
Then you get this window


After that Select the variable as “user::Filepath” under connection String property 

 



 


No comments:

Post a Comment