I have an execute sql task that executes within the package level onerror event. The task will run just fine if it's not within the onerror event, however, if it's sitting in the flow for the onerror event, it just turns yellow, and does nothing.
I have a file task that will complete just fine as well within the onerror event.
SSIS 2008 R2
Thanks,
I ended up using the OnTaskFailed handler instead. That seemed to fit my requirements as much as the OnError event.
Related
I have a package, inside which contains a script task, due to probably C# library issues in some of the servers, this task may success in some machines but fail in others (reporting Cannot load script for execution).
I want to force the task to be success by setting the ForceExecutionResult = Success option for this task. However when running, I found this doesn't work, the task still fails in the old-fashioned way.
I don't want to modify the MaxErrorCount for package because I want to reveal errors from other components, in the meanwhile, even this script task fails during validation, I want the package report success, is there any way to make the solution?
To let your package continue execution, you can set the DelayValidation property to True on the Script Task (so the package will begin executing), then on the Precedence Constraint that follows this Script Task, set it to continue on completion, instead of success.
I am relatively new to SSIS. I have two script tasks. If either task fails, the error handling logic is the same. The second script task must always execute regardless if the first script task has failed.
I have created the above as shown in the image link below. However, It seems the error handler task is only executed once. So if both script tasks terminate in error, the error handler is not executed for the second script task (presumably because it was already executed after the first script task.
Is there anyway to achieve this or do I simply have to duplicate the Error Handler task for both script tasks.
see SSIS Image below
You would need to duplicate the task to have it execute twice.
One way to have this event fire twice while only defining it once is to set up an event handler.
To do this, navigate to the 'Event Handlers' tab.
You'll see there is a dropdown on the right, where you can select the event handler type. Here you'd probably want either OnTaskFailed or OnError. OnTaskFailed fires once per failed task, whereas OnError fires for every error that occurs within a task.
On the left, you can select the executable, which allows you to define a scope for the event handler. If you scope this to the package, you'll have event handlers executed for every task in the package. If there are more tasks in your package than the two Script Tasks you've shown in your post, and you only want it fired for those two, you could put them into a Sequence Container (in the Control Flow), and then scope the event handler to that Sequence Container.
You then just click the text in the middle of the pane to create a handler, and add the necessary tasks there (it works in a similar way to the Control Flow).
The event handler will now execute for both tasks.
It's also worth mentioning that within these handlers are lots of useful system variables you can use, e.g., System::ErrorDescription in OnError.
What I've described will look something like this:
I have created a master control package that calls several packages using the execute package task control. I have set all the package file locations to use a sql config table which contains the file location and then used an expression to include the package name. Everything works as expected however I want to include some handlers to notify me if the package location does not exist (just in case somebody changes the path in the config table). To test I set an incorrect file name in one of the expressions which turned the execute package task control red as expected however I can't figure out how to add the notification task. I have tried all the error handler events assocaited with it but no joy plus I added a mail task to the task in question for failure and this did not execute!
Any advice greatly appreciated.
Thanks.
That's why you have OnError event handler, just configure it properly. Are you sure, you're checking Event Handlers for the package and not for one of the blocks inside?
There's a plenty of system variables with OnError scope. Check grey x in Variable window to see them. You might want to use:
- ErrorDescription
- ErrorCode
- SourceName
but choose them according to the report format.
Now in event handler create a script which will put a message into a new variable, and finally send it with send mail task.
I have an SSIS Package with two steps:
1) FTP in to a server and download a file to the local SQL Server
2) Execute a SQL Satatement, that fires a Storeed Procedure.
Both of these steps work fine, however, I would like to log the success or failure of these steps, so in the system this is for, add a grid with the status (success or failure) of each SSIS Package that runs for that day.
To do this, I have set up an Event handler for the FTP step and added an "Execute SQL Task" to the handler. This uses the "SqlStatementSource" property within Property Expressions, and an insert statement that inserts the system::variables such as System::ErrorCode, System::ErrorDescription.
When I test the expression with the "Evaluate Expression" button, everything is fine. But when I try to test the event by using a wrong password in the FTP connection, the FTP step fails, but the event handler is not raised even though the event handler type is set to OnError.
Any ideas?
Thanks in advance!
What you did seems good, there shouldn't be any problem with that.
Make sure you add the error handler at package level i.e. the top level.
I did the same today, in my case, I was exporting my data to a flat file on local drive
and was using a variable for FilePath.
I used the OnError event handler too.
To check that its working fine or not, I changed the FilePath variable to "Z:\" (which doesnt exists on my system).
and I got the error in OnError event handler like
-1073450982 component "Flat File Destination" (63) failed the pre-execute phase and returned error code 0xC020200E.
-1071636466 Cannot open the datafile "Z:\COM_10212009.txt".
Hope this helps.
In an SSIS package, I have a For Loop Container task with the EvalExpression set to true (so that it runs forever). If any tasks inside the For Loop Container fail, then the package must fail -- except for the Execute Package task (that calls a child package). If that fails, then the parent package should move onto the next task.
I tried setting the MaximumErrorCount of the Execute Package task to 0, but that didn't help.
I tried setting the MaximumErrorCount of the For Loop Container task to 0, but that ignores the errors of all the tasks within the For Loop Container task.
Any idea how I can ignore errors on only the Execute Package task -- within a For Loop Container.
A better way to do this is to go to the OnError handler of your execute package task and set the System variable "Propogate" to false. This will stop the error from bubbling upwards to your loop container.
The answer is to use the FailPackageOnFailure property for all the tasks that should cause the package to stop and set the MaximumErrorCount of the For Loop Container task to 0.
I got the answer here:
http://www.microsoft.com/communities/newsgroups/en-us/default.aspx?&query=Ignore+errors+on+Execute+Package+task+in+SSIS&lang=en&cr=&guid=&sloc=en-us&dg=microsoft.public.sqlserver.dts&p=1&tid=6406db48-a2cb-4b0d-a124-4892e976a583
Go to "Event Handlers" on top
On the left side choose required "Executable:"
Go to "Event Handlers" on top
In the middle click on "Click here to create 'OnError' event handler for executable 'xxx'
Go to "Package Explorer", find newly created 'OnError' event -> Variables -> Propogate
In the properties change value to "false"
Done