SSIS source file with time in the name

  • Hi everyone.

    I have been tasked with building some SSIS packages to load data from a csv into the database each day. There are four file sources. Three of them are very simple because the file name is source_date.csv. The file name is predictable so creating an expression that get the current day's file is easy. One of the files is source_date_time. Because the time stamp is always a few seconds different, I don't know how to create an expression to get the file by name and load it.

    What do people do when they need to have their package go out and grab the day's file if there is a time stamp in the name leading to an unpredictable file name?

  • Use a for each loop.

    There you can use wildcards to find the correct files, for example source_*.csv.

    A small tutorial:

    How to loop through files in a specified folder, load one by one and move to archive folder using SSIS

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • That is a great solution! Thanks Koen.

  • PHXHoward (9/30/2013)


    That is a great solution! Thanks Koen.

    No problem, glad to help 🙂

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • You can also rename the file to your liking and then import.

  • Do you mean use the Foreach loop to rename the file and then use the new fixed file name to load?

    That would work too.

    Thanks

  • ccavaco (10/2/2013)


    You can also rename the file to your liking and then import.

    How would you find the file to rename?

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • You could rename every file in the folder to "name_date". The "good" ones would stay the same and the "bad" would be modified like the others.

  • ccavaco (10/2/2013)


    You could rename every file in the folder to "name_date". The "good" ones would stay the same and the "bad" would be modified like the others.

    So if I have Customer_20131002_230410.txt, Customer_20131002_230412.txt and Customer_20131002_230415.txt, you would rename them all to Customer_20131002.txt?

    This would drop two files in the process.

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

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

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