Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

WMI and moving files Expand / Collapse
Author
Message
Posted Thursday, April 11, 2013 9:38 AM


Mr or Mrs. 500

Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500

Group: General Forum Members
Last Login: Friday, July 4, 2014 3:24 AM
Points: 577, Visits: 379
Okay, maybe not a data warehousing question, but one for the SSIS geniuses out there.

I have a situation where I need to watch a directory for files appearing and then processing them as they arrive. The WMI Event Watcher does a superb job for me in watching the directory and starting the package off - I know the window in which the files will arrive and can set a timeout.

My problem is that one of the files I am expecting is quite substantial in size and I don't want to start processing it until it is all there.

Easy, I thought. Wait for the WMI watcher to kick in and then move all of the files in the directory to another folder where I can process them, if the file is still being copied it will error on that one file (so I thought). I can record the error condition, process the files I have, and then return to check the directory again until either the error condition clears and I have the large file, the directory is empty, or a period of time has elapsed.

I set my test up and was surprised to see the package run successfully and move the file - that was still copying - into the new location, removing it from the watched location. The file was incomplete, and two minutes later the file copy completed with no errors!!

Is there any way, once the WMI has detected a file creation event, I can check to see whether the file I want to move has actually completed it's copy?

Thanks in advance.



---------------------------------------
It is by caffeine alone I set my mind in motion.
It is by the Beans of Java that thoughts acquire speed,
the hands acquire shaking, the shaking becomes a warning.
It is by caffeine alone I set my mind in motion.
Post #1441339
Posted Thursday, April 11, 2013 12:33 PM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Thursday, May 15, 2014 5:11 PM
Points: 6,067, Visits: 5,283
You could setup a script to watch the file for a period of time and see of the file size changes over that time, if it doesn't it could be considered complete if it does then start the wait again..

I've never been particularly a fan of moving files around..

CEWII
Post #1441427
Posted Friday, April 12, 2013 1:04 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 1:08 AM
Points: 5,042, Visits: 11,788
You could maybe try the File Watcher task as an alternative and see whether that works better for you.


Help us to help you. For better, quicker and more-focused answers to your questions, consider following the advice in this link.

When you ask a question (and please do ask a question: "My T-SQL does not work" just doesn't cut it), please provide enough information for us to understand its context.
Post #1441586
Posted Friday, April 12, 2013 3:31 AM


Mr or Mrs. 500

Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500

Group: General Forum Members
Last Login: Friday, July 4, 2014 3:24 AM
Points: 577, Visits: 379
Thanks Phil, the component does exactly what I need and has solved the issue admirably.



---------------------------------------
It is by caffeine alone I set my mind in motion.
It is by the Beans of Java that thoughts acquire speed,
the hands acquire shaking, the shaking becomes a warning.
It is by caffeine alone I set my mind in motion.
Post #1441615
Posted Friday, April 12, 2013 3:39 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 1:08 AM
Points: 5,042, Visits: 11,788
Splendid - thanks for posting back.

Phil



Help us to help you. For better, quicker and more-focused answers to your questions, consider following the advice in this link.

When you ask a question (and please do ask a question: "My T-SQL does not work" just doesn't cut it), please provide enough information for us to understand its context.
Post #1441617
Posted Friday, April 12, 2013 12:35 PM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Saturday, August 23, 2014 8:34 AM
Points: 7,097, Visits: 12,601
Sounds like you are OK with the File Watcher Task, it's a good tool, but I figured I would throw in another option that will help accomplish the same but will not require the installation of a third party component. This one is based on the SSIS Script Task so you can modify the .NET source code in case you need additional functionality down the line:

Using the Script Task in SSIS to Process Data Files When They Arrive


__________________________________________________________________________________________________
There are no special teachers of virtue, because virtue is taught by the whole community. --Plato
Post #1441844
Posted Wednesday, April 24, 2013 7:08 AM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Wednesday, July 30, 2014 10:34 AM
Points: 386, Visits: 624
+1 for the File Wather on SQLIS. We use it all over the place. The 2005 version does not have a pretty config interface but still gets the job done. It needs installing on all dev machines and servers where it may be used.
Post #1445940
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse