how to pick the latest flatfile from a folder.
Hi, I have a task to load data from a flat file to sql. The problem iam facing is, i need to pick the latest file from a folder which has some .txt file with nameing convention as sam_ALL_MMDDYYYY.txt sam_ALL_05122009.txt sam_ALL_12312009.txt sam_ALL_06042010.txt sam_ALL_07052010.txt The package will run on 6th of every month. But i may receive the file before that. so i dont know when will the file be there in my folder. so I need to write an expression to pick the latest file based on date using ssis. Your suggestions please.
July 19th, 2010 5:21pm

Hi, what about using a Script task and finding the right name of the file first, assigning it to a variable and use it in the later flow ? The script could be something like the following LINQ query: var query = from file in DirectoryInfo.GetFiles(@"c:\ThePath", "*.txt") orderby file.CreationTime descending select file.FullName; string str = query.FirstOrDefault(); -JensJens K. Suessmeyer http://blogs.msdn.com/Jenss
Free Windows Admin Tool Kit Click here and download it now
July 19th, 2010 6:35pm

in this blog http://plexussql.blogspot.com/2010/04/delete-oldest-file-in-folder-with-ssis.html i find the oldest file , you can modify the parameter and change it so that is will find the lates file use the loop and the script only to find the newest file my suggestion is try to find the lates file by modify date NOT by the name of the file, Why modify date and not the creation filedate? becuase if you have a file on computer A that has Creationdate 2010-01-20 and modify date 2010-01-26 and you copy (today) the file to computer B the file willbe Creationdate 2010-07-19 and modify date 2010-01-26 that is why you should check the modify date. Sincerely SH -- MVP, MCITP 2008, MCTS 2008 & 2005 -- Please kindly mark the post(s) that answered your question and/or vote for the post(s)
July 19th, 2010 11:18pm

hi shahriar I am new to ssis and had a task to delete the oldest file file from a given folder, i have went through the link http://plexussql.blogspot.com/2010/04/delete-oldest-file-in-folder-with-ssis.html and tried the example but i get an error when i specify the source variable for the file system task as mentioned in the Syep-4 from the example. the error is : "Error 1 Validation error. File System Task File System Task: Variable "OldestFileName" is used as a source or destination and is empty. OLDEST_FILE_DELETE.dtsx 0 0 " so, could you please help me resolve this
Free Windows Admin Tool Kit Click here and download it now
September 4th, 2012 6:17pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics