SSIS Package OnError Logging - ssis

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.

Related

Ssis logging doesnt work in absense of folder

I have setup ssis logging to a text file. In the connection manager I have selected create file and given path as c:\logs\log.txt
Notice that log file is not generated if the log folder is absent. How to ensure that folder is created if not exists? I tried choosing create folder on connection manager but that is also not creating the log file in absence of the c:\log folder.
How to ensure folder is auto created and log is always generated?
You have a chicken and egg scenario here. Consider the following replication of your problem
I have the connection manager driven by a variable LogFileName which generates the date and time. That file lives in whatever folder is specified by LogPath and the first thing my package does is create the folder if it does not already exist. "This thing can run anywhere and all is good." I've said that plenty and have the scars to show for it.
The following shows the events you can choose to log (based on what is in my package).
I am only logging OnPostExecute events. So I'm good, right? Because the post execute event won't fire until after that File System Task has completed.
If that were the case, you wouldn't have posted a question.
The first event that a package generates is a PackageStart event. Look at that list of events - no ability to filter that out. It doesn't matter whether you want that event logged or not, the logging handlers hear the PackageStart event and record it. Always.
The specified Text file logger should be used to record the data and it's ready to record PackageStart to file... "oh that path doesn't exist."
It will exist once the very first task (File System Task, Create Folder) has completed but alas, it it too late. You either get the complete sequence of events or none.
In your Output window, you would see something like the following
SSIS package "C:\Users\bfellows\source\repos\PackageDeploymentModel\PackageDeploymentModel\ChickenAndEgg_Logging.dtsx" starting.
Error: 0xC001404B at ChickenAndEgg_Logging, Log provider "SSIS log provider for Text files": The SSIS logging provider has failed to open the log. Error code: 0x80070003.
The system cannot find the path specified.
Error: 0xC001404B at ChickenAndEgg_Logging, Log provider "SSIS log provider for Text
files": The SSIS logging provider has failed to open the log. Error code: 0x80070003.
The system cannot find the path specified.
SSIS package "C:\Users\bfellows\source\repos\PackageDeploymentModel\PackageDeploymentModel\ChickenAndEgg_Logging.dtsx" finished: Success.
The package will show your Control Flow objects as all having gone green/OK and the status message will say it "Package execution completed with success" but on the results tab, you'll have a red X showing the log provider couldn't open the log.
What do I do
Preconfigure your environments as part of the package deployment process. When we used the native logger as you're inquiring about, we had a document that laid out all that new developers/new servers needed to have done to ensure all of this stuff was laid out and configured as it needed to be.
Unless a client has a strong business case for using the classic logging methodology, I would encourage them to not use it and instead rely on the SSISDB's native logging. It's cleaner, easier to manage, no special setup required. To quote the fine folks in Cupertino - it just works

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 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.