Exporting to CSV

  • I am exporting data from a table to a csv file on an hourly basis. I need the CSV file to have a sequential number suffix.

    So the file created at 9am is ORD0001.CSV.

    Then the file at 10am is ORD0002.CSV and so on.

    I have setup a simple table with the last number used, but I cannot fathom out how to name the file differently each time the Job Runs.

    Thanks.........in anticipation

  • A global variable would be the way to go. Specify the initial file name as your destination connection then prior to Transformation Task in the package insert a dynamic properties task. In that task you could use a SQL Script to change the filename. The script should be a simple select that appends the next logical file number from the table you mentioned earlier.

    Hope this helps.

    David

    David

    @SQLTentmaker

    “He is no fool who gives what he cannot keep to gain that which he cannot lose” - Jim Elliot

  • You can also use the Dynamic Properties task to change the target file based on a select select, which could build the file name.

    Steve Jones

    sjones@sqlservercentral.com

    http://www.sqlservercentral.com/columnists/sjones

    http://www.dkranch.net

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

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