Dynamic File Name

  • I need to create a SSIS package where I will be loading data from a file which will be named as File_name_XXXXXXXX.dat where XXXXXXXX will be the date. Is it possible to create a packake where I can specify File_name_*.dat as a input file and when we run the package every file which meets the criteria is loaded in the DB.

    Thank You,

    Jay Murthy

  • Second try, apparently my last post got eaten...

    You might try using a File System Task to copy the file to a static file name and point your connection object to that static file name. Compute the filename and assign it to an SSIS variable, then In the File System Task, set IsSourcePathVariable to True and set SourceVariable to the name of the variable. Then copy it to the static filename, overwriting the old file. As such File_name_20061005.dat would become File_name_load.dat and your connection could point to the latter.

    The other option is to pass a BULK INSERT command to your SQL Server and load the data into a temporary table. You can script the filename that way as well.

  • Thank You will try this.

  •      Another way to do it would be to use a foreach loop with a wildcard filename (*.dat). Set a variable mapping to get the resolved file name. Then on the connection manager, use an expression for the connectionstring and give it the variable mapped to the resolved file name. One thing to note is you'll probably want to set delay validation on or you'll probably see errors during the validation phase. Hope this helps.

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply