31 December 2016

SSIS Exception Handling via script task C#

Writing a 'Script task' with c# code behind is a walk in the park, however, when the package is scheduled as Job the exception handling is vital key.
There are various permutations needs c# script is included to have needed outcome achieved.
Here is code snippet which can be included either in Catch block of try catch or as success/ failure condition as logic demands

{//your Code logic
catch (Exception ex)
Dts.Events.FireError(0, "- FAILED.", string.Concat("Oops! -", ex.Message.ToString(), "Inner Exception -",ex.InnerException.ToString() ), null, 0);
Dts.TaskResult = (int)ScriptResults.Failure;

Rate Now: