Exporting Data to Flat File- Need to Name Each File Differently with A Date

  • Is there any way to run a Package in a job and have the destination file change its name with every time the job runs? I really want it to have a date in the name but I would be satisfied If I could at least number the files.

  • under expression for the Destination Property to...

    [User::DestinationPath] & "FileName " & (DT_STR,50,1252) GetDate() & ".txt"

    This would create something similary

    [User::DestinationPath] = "C:\MyFolder\"

    Resulting String would be this...

    "C:\MyFolder\FileName 2/29/08 15:00pm.txt

  • When you say user destination to you mean in the Flat File Connection Manager? Or isthere somewhere else? I tried typing it in there and it doesn't work.

  • Create a variable for the path and use get date functions. Click the connection manager for the output text file --> View the properites --> expand "Expressions" --> choose connection string and modifiy the connection string as follows:

    Note: @[User::SharePath] is a variable that holds the path.

    @[User::SharePath] +

    RIGHT("0" + (DT_STR,4,1252) DatePart("yyyy",getdate()),4)+

    Right("0" + (DT_STR,4,1252) DatePart("m",getdate()),2) +

    Right("0" + (DT_STR,4,1252) DatePart("d",getdate()),2) + ".xls"

  • Where do I create the variable?

  • Never Mind. I figured it out and that worked.

    Thank You so Much

  • So I can create the destination but when I run the package it tells me the destination does not exist? Normally I don't have to have the file created prior? Am I doing something wrong? Obviously I am new to this. I normally just use this for importing and exporting data.

  • So I can create the destination but when I run the package it tells me the destination does not exist? Normally I don't have to have the file created prior? Am I doing something wrong? Obviously I am new to this. I normally just use this for importing and exporting data.

    No, the file does not have to exist before running the package. The destination file is set to overwrite by default. Make sure you configured the destitination connection string expression and not the source connection string expression.

  • You can evaluate your connection string in the expression editor. Just click the evaluate button and make sure it is pointing where you want it to.

  • Thanks for your help. I figured out why it wasn't working.

Viewing 10 posts - 1 through 9 (of 9 total)

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