构建文件时处理文件访问锁 [英] Handling file access locks while file is being built

查看:218
本文介绍了构建文件时处理文件访问锁的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个[SQL 2008] SSIS程序包,它使用CSV文本文件并将其移动到单独的文件夹中.将其放入此文件夹后,将数据导入到SQL.外部程序会定期定期自动生成文本文件.该文件也很大,因此生成它需要一段时间(约10分钟).

I have a [SQL 2008] SSIS package that takes a CSV text file and moves it to a separate folder. Once it is in this folder, I import the data to SQL. The text file is being automatically generated by an outside program on a periodic schedule. The file is also pretty large, so it takes a while (~10 minutes) for it to be generated.

如果我尝试移动此文件(使用文件系统任务)文件中仍在构建中,则会收到以下错误消息:

If I attempt to move this file (using a File System Task) WHILE the file is still being built, I get this error message:

该进程无法访问该文件,因为该文件正在被另一个进程使用."

这很有意义,因为它无法将正在访问的文件移动到其他位置.回到DTS中,我编写了一些自定义脚本来检查XX秒,以查看文件大小是否已增加,但是我想知道如何在SSIS中正确处理此问题.当然,执行文件操作之前,有一种更好的方法来确定文件是否已锁定.

Which makes sense, since it can't move a file that is being accessed elsewhere. Back in DTS I wrote some custom script to check for a period of XX seconds to see if the file size had increased, but I was wondering how to handle this properly in SSIS. Surely there is a better way to determine if a file has locks on it before doing file operations.

我将不胜感激任何建议或评论!谢谢.

I would greatly appreciate any suggestions or comments! Thank you.

推荐答案

可能您已经找到问题的答案.这是给可能偶然发现此问题的其他人的.

Probably, you have found an answer to your question by now. This is for others who might stumble upon this question.

要实现问题中已描述的功能,可以使用File Watcher Task,可从网站SQLIS.com免费下载.

To achieve the functionality that you have described in your question, you can use the File Watcher Task that is available for free download from the website SQLIS.com.Click the link to visit File Watcher Task download page.

希望有帮助.

这篇关于构建文件时处理文件访问锁的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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