Monday 29 September 2014

Create a folder with current date



Here i am going to explain, how to create a folder (folder name is current date 'YYYYMMDD') in SSIS using 'File System Task'.

  • Create three variables
    • Folder_Path
    • Folder_Name
    • Full_Path
Give the required path for the variable "Folder_Path", and writhe expression for the variables 'File_Name' and 'Full_Path' (Use the below expressions).

Variable NameData TypeValue/Expression
Folder_PathStringD:\ (Give required path)
Folder_NameStringSUBSTRING((DT_WSTR, 10) (DT_DBDATE) GETDATE(), 1,4)
+SUBSTRING((DT_WSTR, 10) (DT_DBDATE) GETDATE(), 6,2)
+SUBSTRING((DT_WSTR, 10) (DT_DBDATE) GETDATE(), 9,2) 
Full_PathString@[User::Folder_Path]+ @[User::Folder_Name]










  • Take 'File System Task' and edit.
  • Select "Operation" as "Create Directory" from the drop-down list.
  • Set "IsSourcePathVariable" as "True"
  • Select "Full_Path" Variable from the "SourceVariable" Drop-down list.
 
  • Click on "OK" Button and run the package.


1 comment:

  1. this is not working , i am getting error "Failed to lock variable"

    ReplyDelete