Solved

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

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Via a live example, show how to shrink a transaction log file down to a reasonable size.

726 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