2

If a file system task such as a rename fails, for example if the file does not exist, then this is considered an error by SSIS. This means the whole package fails. I can get around it by using a script task, or setting the maximum errors for the package to more than one. The problem with setting maximum errors for the package to more than one is that if an error occurs somewhere else in the package the package won't fail when it should.

So is there any way to somehow swallow the error and still be able to branch based on success or failure of the file system task? I tried sticking the file task into a sequence container with ForceExecutionResult set to Success, but the package still fails saying maximum error count reached.

9 Answers 9

10

Here is one possible option. You can achieve the requirements mentioned in the question by changing the Precedence Constraint after the File System Task to Completion. Following example shows how this can be done. The example was created using SSIS 2008 R2 but holds true for previous versions as well.

Step-by-step process:

  1. Create an SSIS package and create two variables as shown in screenshot #1. Assign some non-existent file path values to the variable.

  2. On the package's Control Flow tab, place a File System Task, Script Task and Data Flow Task as shown in screenshot #2. Script Task and Data Flow Task are dummy here and the tasks are not configured to do any actions.

  3. Configure the File System Task as shown in screenshot #3.

  4. Screenshot #4 shows package execution and as expected the File System Task failed because the file paths don't exist. Also, the package stopped executing the tasks after the File System Task because of the error.

  5. Right-click on the Precedence constraint arrow between File System Task and Script Task and select Completion as shown in screenshot #5. The arrow should turn from green color to blue color.

  6. Screenshot #6 shows package execution after the precedence constraint change. The File System Task still failed but the other tasks continued to execute. Earlier, the condition was to execute the Script Task only if the File System Task succeeded. Now, the condition is to execute the Script Task after File System Task completes its execution (irrespective of Success or Failure).

  7. If you would like to have the package take completely two different paths based on success/failure. You can do so as shown in screenshots #7 and #8. The red arrow indicates that the path will be taken on Failure of the File System Task and the green arrow indicates that path will be taken on Successful execution of the File System Task. I had a file created in the path C:\temp\Source.txt before the execution of package shown in screenshot #7. Once the package executed, the file was renamed and the path was no longer. Hence, the package failed as shown in screenshot #8.

Hope that helps.

Screenshot #1:

1

Screenshot #2:

2

Screenshot #3:

3

Screenshot #4:

4

Screenshot #5:

5

Screenshot #6:

6

Screenshot #7:

7

Screenshot #8:

8

1
  • What if I have a Drop Table, Prepare SQL Table and a Data Flow task already in my package. How does the setup change for me?
    – Si8
    Apr 14, 2014 at 20:13
2

Check the FailPackageOnFailure and FailParentOnFailure properties of the FileSystem task and make sure they are set to False. Also, increase the MaximumErrorCount property of the package.

This combination will allow the task to fail and the package to still complete successfully.

2
  • FailPackageOnFailure and FailParentOnFailure are false. (As I mention in my question) I can increase the MaximumErrorCount - but this will mean other errors elsewhere in the package go unspotted. It seems the choice is: lax error checking on no FS task.
    – Simon D
    Feb 4, 2009 at 18:58
  • 1
    If you have other items that are important, you can set FailPackageOnFailure to True for those items. Then the package will fail even with an increased MaximumErrorCount. You can also add error handling tasks to decide weather to fail the package or not based on the error.
    – Rob Boek
    Feb 6, 2009 at 5:48
1

Make the property "Force execution Result" to success for the File system task..

0

I've run into this exact problem and I've always used a Script Task. I don't think there's a better solution.

0
0

I haven't tried this with a FS task, but it works well for dataflows... What about wrapping your filesystem task in a sequence container... If the step fails, the container fails, you could simply output from the container to a success/failure path....

1
  • Thanks for the suggestion - I tried using a sequence container but the fact there has been an error in the flow means the package reaches its MaximumErrorCount and fails. I guess Rob's right - no way to do this, which makes the file system task pretty brittle.
    – Simon D
    Jan 30, 2009 at 14:04
0

You can use constraint on the connection. Right Click on the connection arrow between SSIS components and you can specify,

Success/Failure and redirect.

0

prashant_sp answer is the right one, you just have to continue unconditionnally to the next task, by not selecting the "on success" workflow precedence constraint, but the "redirect" one which will always continue, even if your FS task fails (folder does not exist, etc...)

Kind regards

0

Use a expression and constraint combination on the "precedence constraint" connector. return success always from your previous task (it may be a script looking for the file) and if file found, set a variable. in the expression of the "precedence constraint" check for the variable value and return true or false. If your expression evaluates to false, the package will nto continue and yet you will not see any error. - Mayukh

0

I know that this is an old question, but it might help someone looking for an answer.

Combined with user756519's quite good answer, stopping propagation of the error prevents the package from failing. This means that you can effectively use the failure as a branch without worrying about it mincing your package.

See cfrag's answer on this question for more information. That answer points to this blog entry which explains how to set the propagate variable for the OnError event handler (make the event handler, open variables view, show system variables, set Propogate to false).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.