Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
goodsolution
Starting Member
38 Posts |
Posted - 2009-05-11 : 10:29:27
|
Hi all, I have 4 files in "c:\Files" location and file names as followsSystem_02252009.xlsmSystem_03252009.xlsmSystem_04252009.xlsmSystem_05252009.xlsmNow i need to pick up the latest file (i.e.System_05252009.xlsm)and that need to be pass to my source connection string.How can i achieve this target? I know we have to use For each loop container for it, but i dont know the procedure.Your help would be appreciated. -Thanks |
|
YellowBug
Aged Yak Warrior
616 Posts |
Posted - 2009-05-13 : 14:36:04
|
Suggest using a script task, inside the ForEach Loop.Here is the psuedo-code: File = CStr(Dts.Variables.Item("User::vFileName").Value) If IsNull(sNewestFile) Then sNewestFile = File dPrevDate = File.DateLastModified Elseif dPrevDate < File.DateLastModified Then sNewestFile = File dPrevDate = File.DateLastModified End If |
 |
|
|
|
|