Thursday, April 22, 2010

Create a dynamic incremented folder in SSIS

So I have a SSIS package that needs to put files it generates in a new, incremented folder.  Here's what I ended up doing:
  • Created a counter table with one column "dfgcounter"
  • Created a variable in my package named DFGCounter
  • Created a "New DFG" File Connection
    • Created a ConnectionString expression: ''\\\\servername\\subfolders\\CCMSI"+ @[User::DFGCounter]
  • Created an Execute SQL Task
    • Selected MAX dfgcounter and put it into Result Set mapped to Variable User::DFGCounter
    • Note: the value will not show in the variables window... caused me to think there was something wrong with the SQL Task
  • Created a File System Task
    • Operation: Create Directory
    • Source Connection: "New DFG" File Connection that was created earlier
  • File System Tasks moving the file(s) to the New DFG File Connection
  • Data Flow Task
    • Derived column taking the DFGCounter + 1 and inserting it into the dfgcounter table

No comments:

Post a Comment