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)
 Latest File to Load in DB

Author  Topic 

gvgonong
Starting Member

6 Posts

Posted - 2008-08-16 : 09:16:29
I have a flat file named 20080808File.txt, and the next day it will add another file named 20080809File.txt in the source folder. the date part represent the day it was extracted from its source. I want to make sure that my package doesn't only look from the specific filename (i.e. C:\Source\20080809.txt), because after it load this file will move to archive folder. What i need to do is that the package should look for the latest file from the source folder and load it to database base on the current date.

Any help would be appreciated.
TIA

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2008-08-16 : 09:56:15
You need File Watcher task:
http://www.sqlis.com/23.aspx
Go to Top of Page

gvgonong
Starting Member

6 Posts

Posted - 2008-08-16 : 11:12:26
Thanks sodeep for the quick reply. The problem using the File Watcher is that it has some issues when placing to For Each Loop Task, based on this links:
http://www.sqlservercentral.com/Forums/Topic493253-148-1.aspx http://blogs.conchango.com/jamiethomson/archive/2006/10/18/SSIS_3A00_-Random-information-for-beginners.aspx.

Although it answer my question, is there other way to do this without using File Watcher?

Also, can anyone recommend any suggestions because I was thinking of removing the date stamp from the source folder (C:\Source\20080808File.txt to C:\Source\Loader\File.txt) and then load the File.txt to the database. After the loading, rename again to bring back the date stamp and move the file into Archive.

The flow should be like this:
(C:\Source\20080808File.txt To C:\Source\Loader\File.txt To C:\Source\Archive\20080808File.txt)
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-08-17 : 04:59:50
I think what you could try is to get the creation time of all files in folder using script task below and then compare them and select maximum value among them. then use the file having maximum file as one which is to be transfered.

http://www.mydatabasesupport.com/forums/sqlserver-dts/184478-script-task-how-get-file-getcreationtime.html
Go to Top of Page
   

- Advertisement -