SSIS Execute Package task notification if path does not exist - ssis

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.

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 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 package script logging

I am new to SSIS packages and I am trying to get logging to work from within a custom script. We have it logging the native messages from the package already but I want to add my own custom log messages to it. I see on the Microsoft.SqlServer.Dts.Pipeline.ScriptComponent class there is a Log method but I am unsure what to use for the dataCode and dataBytes arguments so I used 0 and an empty array but this did not log anything.
So how do I get the logging to work from within my script?
Are there any configurations that I need to know about to enable it?
Thanks
Note: I am working with SqlServer 2008 SP2 (not R2)
You need to make sure that the task is enabled for logging. Select SSIS > Logging... from the BIDS menu. Select your data flow task. On the Providers and Logs tab, ensure that a log provider is selected. Select the Details tab and Check the ScriptComponentLogEntry event. Note that this event is not inherited from the Package settings; so you have to select the data flow task. Now your logging should be captured.
You may also be interested in the ComponentMetaData.FireInformation method to log an information event. Here's more information on FireInformation and related methods. You may find these easier to configure, since the associated events (OnInformation for FireInformation) are inherited from the package settings. In other words, if you set logging for the OnInformation event at the package level, all tasks will log the OnInformation event.

SSIS Configuration problem: not returning SQL Server Table config values

This was posted on server fault, but in retrospect that may not be the best spot for it, so I've moved it here.
I have a package that runs fine on my dev machine but in production (and also on another dev desktop) the Config seems to stop working. I'm using SQL Server Table configuration to pull a value from a table and populate a variable. My Database connection string is passed in at runtime so this should be taken care of in the production environment. There are no errors, but the value is not retrieved and the variable remains blank (it is actually a path, so I get a file not found as the path is blank).
The package works on my machine. It retrieves the correct path from the table and populates the variable as expected. Why this stops working with no error elsewhere is a mystery. Is there someplace that configuration needs to be 'switched on', apart from the checkbox on the front page of the config wizard.
Try Event Handlers
1. Select Event Handler OnVariableValueChanged
2. Add a script task to the pane
3. Pass in System::VariableName,System::VariableValue as InputVariables
4. Add the following to the code:
Public Sub Main()
Dts.Events.FireInformation(0, "VariableChangedEventLog", "Variable " & Dts.Variables("System::VariableName").Value.ToString() & " Changed to:- " & Dts.Variables("System::VariableValue").Value.ToString(), "", 0, True)
Dts.TaskResult = Dts.Results.Success
End Sub
This will print out the variables and will at least give you an indication of whether the correct values are passed into the package.
I have the problem that my package receives the correct configuration file, but then is not passing this value onto my child packages. May well post a link to a new post on this.

SSIS Package OnError Logging

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.