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,532 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
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
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 

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 65

Accepted Solution

by:
Jim Horn earned 500 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 65

Expert Comment

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

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Suggested Solutions

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Viewers will learn how the fundamental information of how to create a table.

773 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