?
Solved

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

Posted on 2014-03-28
2
Medium Priority
?
3,125 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
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
Suggested Courses

752 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