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.

 All Forums
 SQL Server 2005 Forums
 SSIS and Import/Export (2005)
 About For Each Loop Container

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 follows

System_02252009.xlsm
System_03252009.xlsm
System_04252009.xlsm
System_05252009.xlsm


Now 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
Go to Top of Page
   

- Advertisement -