Solved

SSIS: If a task fails, how do I make the package continue to the next step (and not fail) but log the error

Posted on 2008-10-06
14
1,525 Views
Last Modified: 2012-05-05
Hi experts,

I have an SSIS package on SQL Server 2005. It has many steps and several variables, all working ok.

Everything works fine, until a step fails. The whole package stops. I dont' want that to happen. Instead, if the step fails (it's an Execute SQL step, and I'm running a stored proc that does not return anything, but there is a TRY..CATCH Exception in there which causes the failure of the package), then I want to log the error and carry on.

I have a precedence constraint coming from the step to the next step. A "success" constraint path, and a "failure" constraint path.. but the failure step is never reached even though the step is indeed failing.

I have set FailaPackageOnFailure to True on the step itself, but still no joy.

Any suggestions?

Thank you,
rss2
0
Comment
Question by:rss2
  • 7
  • 5
  • 2
14 Comments
 
LVL 60

Expert Comment

by:chapmandew
Comment Utility
>> FailaPackageOnFailure
Shouldn't it be set to False?
0
 

Author Comment

by:rss2
Comment Utility
Intuitively, yes, that's what I thought. False is the default. But I read somewhere to set it to true for what I want to do..so, dont' know. I'll look into that some more.

But regardless, still doesn't change anything, whether that value is left blank, set to True or set to False.

Any ideas?
0
 
LVL 60

Expert Comment

by:chapmandew
Comment Utility
Ok...look at the screenshot I listed.  In it execute sql task that failed, I have :  SELECT 1/0  which will always cause an error.  In the precedence (error) I just do a SELECT GETDATE(), but you can see that it went to that execute task, even after the first error.
precedence.JPG
0
 

Author Comment

by:rss2
Comment Utility
I did your example and indeed I get what you get. But back in my package, it's not working.

The step that's failing is an Execute SQL step that's running a stored procedure. I have a RAISERROR in the stored proc. When I remove that, the step continues as successful but that's not true.

I have no idea what the problem could be here. :(
0
 
LVL 60

Expert Comment

by:chapmandew
Comment Utility
What is the reason of the failure?
0
 

Author Comment

by:rss2
Comment Utility
There's an insert that is trying to be executed and the error message is:
String or binary data would be truncated.
0
 
LVL 60

Expert Comment

by:chapmandew
Comment Utility
try taking the try...catch out and remove the raiseerror.
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 

Author Comment

by:rss2
Comment Utility
When I take the try..catch out, and the raiserror, the stored proc still fails of course which is what I'm expecting. But the package step just fails, and despite the failure precedence constraint the entire package stops execution. (i.e. The execute sql step box turns red and the whole thing stops.)

??
0
 

Author Comment

by:rss2
Comment Utility
I had the failure precedence constraint connected to an Execute SQL task that has another connection to it. When I removed that, and created a new one especially for the failure precedence constaint, it worked. Weird!
0
 

Author Comment

by:rss2
Comment Utility
So now the failed step is continuing onto the next step, which executes successfully.

But I'm still getting the problem of the entire package stopping due to the failure, per my question. How do I make the package keep running even though one of the steps fails?

Thanks!
0
 

Author Comment

by:rss2
Comment Utility
As an aside, the issue that was causing the failure of the SQL step was, as I mentioned above, due to too big a string attempting to be inserted into a smaller data type (i.e. trying to push a square into a triangle-shaped hole).

I thought this issue was weird, because all I was doing was taking the raw imported data from a flat file pulled into a sql table.

Turns out, SQL was mixing the rows. So the order of the flat-file was in fact not the order that result in a select on that import table.
http://www.microsoft.com/communities/newsgroups/en-us/default.aspx?dg=microsoft.public.sqlserver.integrationsvcs&tid=1cf7c669-1d6c-4dfe-88de-9ce07fd4289a&cat=&lang=&cr=&sloc=&p=1

I believe this is a bug in SQL, but as a work around, I made sure I truncated the staging table that took the raw data in from the flat file (as opposed to a simple delete) before importing the raw data.

Now I don't get that failure on that step anymore!

rss2
0
 
LVL 60

Expert Comment

by:chapmandew
Comment Utility
did you set FailaPackageOnFailure back to false?
0
 
LVL 65

Accepted Solution

by:
Jim Horn earned 500 total points
Comment Utility
{not sure if this helps, but...}
In your script code, you can raise an error in the code (as opposed to the SP) with the below line of code (modify to suit your needs)

Dts.Events.FireError(-1, "N/A", sErrorDescription, "", 0)
0
 
LVL 65

Expert Comment

by:Jim Horn
Comment Utility
Thanks for the grade.  Good luck with your project.  -Jim
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now