Solved

SSIS ForEach File Loop:  How to determine most recent file in a folder

Posted on 2014-03-28
2
2,499 Views
Last Modified: 2016-02-10
Hi guys

I have an SSIS 2012 package, with a ForEach loop that goes through a folder.

Question:  Does anyone know how to pull of 'How to determine the file with the most recent 'Date Modified'?   My source folder will contain a full-load file generated each day, and my task is to use the most recent file, and delete the rest.
ssis-for-each-file-loop-how-to-g.jpgThanks in advance.
Jim
0
Comment
Question by:Jim Horn
2 Comments
 
LVL 9

Accepted Solution

by:
edtechdba earned 500 total points
ID: 39961767
Greetings Jim,

It sounds like this article may be of use to you.

SSIS -How To Get Most Recent File from Directory And Load To a Table [ SSIS Script Task ]
http://sqlage.blogspot.com/2013/12/ssis-how-to-get-most-recent-file-from.html

- This script task is written in C#, not sure if you use that or VB.NET, however the logical process should be the same.
0
 
LVL 65

Assisted Solution

by:Jim Horn
Jim Horn earned 0 total points
ID: 40007058
Figured it out, mostly from the link.

Changed the loop to get files to a script taskChanged source file grabbing to a script taskHere's the precedence constraint for if it found a file.  
For the 'found no files' arrow then change != "" to == "".Precedence Constraint - File Found Here's the Script TaskCThanks.
Jim
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

SQL Server  2012 Release with lots of Enhancements in Database Engine functions, SSIS, SSRS and some of new services like Data Quality Server and Master Data Service. Of particular interest, and the focus of this Article is SSIS. So, time to elab…
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now