Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


File System Task > Move Files > Error - Process cannot access the file because its being used...


File System Task > Move Files > Error - Process cannot access the file because its being used by another process

Author
Message
chrismgarvey
chrismgarvey
SSC Rookie
SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)

Group: General Forum Members
Points: 30 Visits: 160
Hi,

I have 2 foreach loop containers within my control flow:

The first foreach loop container loops through a directory and loads files into a table

The second foreach loop container loops through the same directory and moves the files to an archive directory.

When executing the package I receive the following error message:

[File System Task] Error: An error occurred with the following error message: "The process cannot access the file because it is being used by another process".

Any suggestions would be greatly appreciated.

Regards,
Chris
Phil Parkin
Phil Parkin
SSCrazy Eights
SSCrazy Eights (8.4K reputation)SSCrazy Eights (8.4K reputation)SSCrazy Eights (8.4K reputation)SSCrazy Eights (8.4K reputation)SSCrazy Eights (8.4K reputation)SSCrazy Eights (8.4K reputation)SSCrazy Eights (8.4K reputation)SSCrazy Eights (8.4K reputation)

Group: General Forum Members
Points: 8414 Visits: 19517
Why not use a single Foreach loop to do the entire load/archive process?


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

If the answer to your question can be found with a brief Google search, please perform the search yourself, rather than expecting one of the SSC members to do it for you.

Please surround any code or links you post with the appropriate IFCode formatting tags. It helps readability a lot.
chrismgarvey
chrismgarvey
SSC Rookie
SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)

Group: General Forum Members
Points: 30 Visits: 160
Hi Phil,

I've already tried this and receive the same error

Chris
chrismgarvey
chrismgarvey
SSC Rookie
SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)

Group: General Forum Members
Points: 30 Visits: 160
Full details of package as follows:

Loop 1 (looks for Excel file)
loop2 (looks for Excel sheet using ado.net schema rowset)
DFT
End loop 1
End loop 2
|
|
\/
Loop 3
Move file
End Loop3

Could the ado.net schema rowset, be causing issues?

Chris
Aparna-1
Aparna-1
SSC Veteran
SSC Veteran (259 reputation)SSC Veteran (259 reputation)SSC Veteran (259 reputation)SSC Veteran (259 reputation)SSC Veteran (259 reputation)SSC Veteran (259 reputation)SSC Veteran (259 reputation)SSC Veteran (259 reputation)

Group: General Forum Members
Points: 259 Visits: 601
It might be possible that the file download on your source directory is not complete and at the same instance you are trying to move the file. 2 Processes are accessing the same resource.

Create an onfailure event and loop through the rest of the files in the folder or write a script task to Open each file (catch an exception if the file cannot be open) before moving.
Rocco.Sansotta
Rocco.Sansotta
Forum Newbie
Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)

Group: General Forum Members
Points: 4 Visits: 61
Since this took me MANY HOURS to solve, I'm posting my solution for others. And it was sooo simple...

Place a copy of your Excel File in another folder and name it "template.xlsx". Have your Schema connection point to this copy. The actual Excel file will no longer be kept locked by the ForEach Worksheet Schema loop!
amendieta
amendieta
Forum Newbie
Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)

Group: General Forum Members
Points: 7 Visits: 64
Thank you sooo much. After many days - this is the only solution that worked.:-)
MMartin1
MMartin1
Ten Centuries
Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)

Group: General Forum Members
Points: 1128 Visits: 2015
Rather than maintain two copies of the same file, Import then move the file all in one loop.

----------------------------------------------------
How to post forum questions to get the best help
superi
superi
SSC Rookie
SSC Rookie (31 reputation)SSC Rookie (31 reputation)SSC Rookie (31 reputation)SSC Rookie (31 reputation)SSC Rookie (31 reputation)SSC Rookie (31 reputation)SSC Rookie (31 reputation)SSC Rookie (31 reputation)

Group: General Forum Members
Points: 31 Visits: 58
Well, i saw the same issue & there is a property on Excel connection manger "RetainSameConnection". If you set this to "False" , Viola, the error disappears!
superi
superi
SSC Rookie
SSC Rookie (31 reputation)SSC Rookie (31 reputation)SSC Rookie (31 reputation)SSC Rookie (31 reputation)SSC Rookie (31 reputation)SSC Rookie (31 reputation)SSC Rookie (31 reputation)SSC Rookie (31 reputation)

Group: General Forum Members
Points: 31 Visits: 58
Well, i saw the same issue & there is a property on Excel connection manger "RetainSameConnection". If you set this to "False" , Viola, the error disappears!
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search