[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 2014-03-28
2
Medium Priority
?
3,407 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 2000 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 66

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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
One of the most important things in an application is the query performance. This article intends to give you good tips to improve the performance of your queries.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Viewers will learn how the fundamental information of how to create a table.
Suggested Courses

865 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