Solved

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

Posted on 2014-03-28
2
2,765 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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Binding error when running a view SQL Server 3 27
SQL: Get Holding Day Based On Transfer Date And Return Date 13 73
SQL query and VBA 5 46
Database Integrity 1 50
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…
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

839 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