Execute SSIS Task More Than Once - ssis

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:

Related

SSIS event handler script task

i have a package that has several event handlers that execute a script task on failure when the package fails.. Problem is its generating a email that i have NO IDEA how.. When the package fails it executes a stored procedure that grabs the email distribution list from a SQL table and sends an email. However one email is being sent out to ppl who are not with the company and ive been told twice to change the DL list.. I checked the SQL table and the people that are getting the email are not listed any where in the distribution list.. Is there any way to search anywhere in the package to find out how the email is being generated. Ive spent hours and hours going through the scrip tasks and the code is no where to be found
You can use the package explorer (to the right of the event handler tab) to navigate through the entire package and look at the event handlers for every executable. It's possible that there are multiple event handlers, one at the package level and maybe one defined on a particular task, which is hardcoded with email addresses.
You can also, right click on the package in the solution explorer and select View Code. This will open the package in xml, which you can then use ctrl+F to find a certain string.
Advice Section
While you didn't ask for it, please let me add a few words of guidance. Event handlers are evil for this very reason. They are a hidden GOTO that you are lucky to notice at all, even if you've developed the package in the first place.
If event handling is required, use the precedence constraints in the control flow. Throw everything in a container, connect it to the script task and define the constraint to trigger on failure.
To go one step further, keep your emails out of your ssis packages. Use SQL agent or whatever scheduler you are using to post messages about failures.

SSIS ForceExecutionResult not working

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.

SSIS Execute Package task notification if path does not exist

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.

SSIS 2008 User Variable in Expression for Execute Process Task

I have an SSIS 2008 package.
I have 3 user variables in the package. One is for an the environment, one is for the path for an executable, and the other is part of a message for an email.
I have a Script Task that sets the variable for the path (strAppPath) based on the environment variable.
strAppPath is used in an expression for the Executable property of an Execute Process Task. The job fails stating that the executable path for the Execute Process Task is not set.
I'm assuming that it is checking this path before the Script Task sets the variable.
Is there a way to work around this?
Right click on your Execute Process Task and select Properties. In the properties window, you will have a DelayValidation option that is currently set to False Flip that to True.
What is happening is that when the package starts, it goes through a validation phase to ensure everything is kosher before it begins (no need to start processing if something is broken). In your case, that full validation is not desired as the Execute Process Task won't be valid until right before it's time to run. The validation will occur, just that it is delayed until it is time for the task to begin. Make sense?

SSIS onerror event. Execute SQL task just sits there

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.