nosirrahcd
nosirrahcd

Reputation: 1467

SSIS -- Allow a task to fail but have the package succeed?

Is there a way to allow a script task to fail, yet have the package execution result based only on the other tasks' execution results? For example, I have 5 tasks. I don't care what task 2's result is, but if any of the others fail, I want the package to fail. Otherwise, I want it to succeed...

This possible?

Upvotes: 7

Views: 14833

Answers (2)

squillman
squillman

Reputation: 13641

As well as setting FailPackageOnFailure on the task you should also set MaximumErrorCount on the package itself to something greater than 1. The task will still increment the packages error count and if the error count exceeds MaximumErrorCount then the package can/will still fail.

Upvotes: 5

Ilya Berdichevsky
Ilya Berdichevsky

Reputation: 1298

Try setting FailPackageOnFailure to False in the Task's Properties.

Next option will not actually fail your tasks, but may work for you: Try wrapping your code into try catch and use finally to set Success for 2 tasks that you don't care about.

        try
        {
           // Do work here 
        }
        catch
        {
            // log errors here
        }
        finally
        {
            Dts.TaskResult = (int)ScriptResults.Success;
        }

Upvotes: 4

Related Questions