Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
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
Medium Priority
?
1,667 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 5
  • 2
14 Comments
 
LVL 60

Expert Comment

by:chapmandew
ID: 22652047
>> FailaPackageOnFailure
Shouldn't it be set to False?
0
 

Author Comment

by:rss2
ID: 22652108
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
ID: 22652197
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:rss2
ID: 22652341
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
ID: 22652381
What is the reason of the failure?
0
 

Author Comment

by:rss2
ID: 22652416
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
ID: 22652475
try taking the try...catch out and remove the raiseerror.
0
 

Author Comment

by:rss2
ID: 22657200
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
ID: 22657336
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
ID: 22657416
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
ID: 22657935
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
ID: 22658480
did you set FailaPackageOnFailure back to false?
0
 
LVL 66

Accepted Solution

by:
Jim Horn earned 2000 total points
ID: 22659417
{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 66

Expert Comment

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

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
This month, Experts Exchange sat down with resident SQL expert, Jim Horn, for an in-depth look into the makings of a successful career in SQL.
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
Via a live example, show how to shrink a transaction log file down to a reasonable size.

636 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