如何使用文件夹中的最新文件作为源 [英] How to use the latest file in a folder for source

查看:76
本文介绍了如何使用文件夹中的最新文件作为源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个SSIS软件包,它可以提取CSV文件进行处理,可以为源\\server\dash\LABORDERS.CSV提取一个文件,并且运行良好.

I have an SSIS package which pulls in a CSV file for processing which pulls one file for the source \\server\dash\LABORDERS.CSV and is working fine.

我们希望保留较旧的文件以用于历史目的,因此每天都会有新文件,而不仅仅是覆盖旧文件,看起来像这样:

We wanted to keep older files for historic purposes so everyday there will be new files instead of just overwriting the old one and it looks like this:

我知道我想添加一个脚本任务,但是我不确定在哪里添加它以及如何调用它,以便源文件始终在文件夹中寻找最新文件,并使用该文件将数据传输到这是sql的目标.

I know I am suppose to add a script task but I am not sure where to add it and how to invoke it so that the source file is always looking in the folder for the latest file and using that file to transfer data to it's sql destination.

我该如何实现?

推荐答案

您尝试了什么?您可以在控制流的开头创建脚本任务,该脚本任务使用.NET Framework文件系统对象搜索目录并获取具有最新时间戳的文件.然后,您可以将该文件名分配给SSIS变量,然后在文件连接管理器中使用该变量.

What have you tried? You can could create a script task at the start of your control flow that uses the .NET framework filesystem objects to search a directory and get the file with the most recent timestamp. You could then assign that file name to a SSIS Variable, then use that variable in your file connection manager.

这篇关于如何使用文件夹中的最新文件作为源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆