source file name dynmically changes

  • Hi all,

    i am creating a ssis package to import a flat file to a table.

    i get the files every day with different names.

    how to configure the data flow task for this scenario.

    for example, i get a file today with name file1 and tommorow with file2 and these have to be imported

    into a table.

    thank you.

  • [font="Comic Sans MS"]

    i get a file today with name file1 and tommorow with file2 and these have to be imported ..

    file1 and file2 doesn't suffice - you should be specific. In case the filename doesn't follow a pattern (which is most unlikely) it's a bit complex to achieve..

    Whereas if it follows a patter - example - filename_ddmmyyyy it's fairly simple. You would need to use variable to indentify the date and then use expression for the flatfile source ...

    There are few other ways - like using for each loop container etc to achive the same but it depends on specifics of your requirement.

    In case you need more assistance - you can search this forum because this topic has been already discussed several times as I remember 😉 or it would be easier if you can post your requirement with more exact details.

    [/font]

    [font="Comic Sans MS"]--
    Sabya[/font]

  • Personally, I'd need more specifics regarding your requirements. You indicate that each day the filename changes, but when you say file1 one day then file2 the next, is the number at the end the only change? Does the filename actually contain more information? Can you get multiple files in the same day?

  • Hi Guys,

    I too need solution to the same problem.The file names I have follow a certain pattern but littel bit tricky.They are like

    ABC_DE_r5115.ab.006.200903xx (file 1) and ABC_DE_r5115.cd.006.200908xs .Only the part until ABC_DE_r5115 remains the same.......

  • srikantzs (12/16/2009)


    Hi Guys,

    I too need solution to the same problem.The file names I have follow a certain pattern but littel bit tricky.They are like

    ABC_DE_r5115.ab.006.200903xx (file 1) and ABC_DE_r5115.cd.006.200908xs .Only the part until ABC_DE_r5115 remains the same.......

    [font="Comic Sans MS"]

    You can you ABC_DE_r5115.??.???.* or ABC_DE_r5115.* format to get the filenames.. use for each loop container. See example in the link below:

    http://www.sqlis.com/post/Looping-over-files-with-the-Foreach-Loop.aspx

    [/font]

    [font="Comic Sans MS"]--
    Sabya[/font]

  • Other than using the Foe each loop container, i used a script task to read file name into a variable and used it as an expressions at the file connection manager (source)

  • Thanks for the help guys...It did work for me using for each loop and I think I should go ahead with foreach because I might be getting multiple files in a day.....and my package should execute every 5 mins.......

Viewing 7 posts - 1 through 6 (of 6 total)

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