<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://sqlblog.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Rushabh Mehta  : Event Handler</title><link>http://sqlblog.com/blogs/rushabh_mehta/archive/tags/Event+Handler/default.aspx</link><description>Tags: Event Handler</description><dc:language>en</dc:language><generator>CommunityServer 2.1 SP2 (Build: 61129.1)</generator><item><title>Gracefully Handing Task Error in SSIS Package</title><link>http://sqlblog.com/blogs/rushabh_mehta/archive/2008/04/24/gracefully-handing-task-error-in-ssis-package.aspx</link><pubDate>Thu, 24 Apr 2008 11:46:00 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:6378</guid><dc:creator>RMehta</dc:creator><slash:comments>46</slash:comments><comments>http://sqlblog.com/blogs/rushabh_mehta/comments/6378.aspx</comments><wfw:commentRss>http://sqlblog.com/blogs/rushabh_mehta/commentrss.aspx?PostID=6378</wfw:commentRss><description>&lt;P class=MsoNormal style="MARGIN:0in 0in 10pt;"&gt;&lt;SPAN style="COLOR:#1f497d;mso-themecolor:text2;"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;I am sure that there is already some blog or article about this. But, I encountered this today and decided to go ahead and blog anyway. I had a situation, where I expected at certain times (the first of every month), a task to fail, but regardless, I wanted the package to continue to run with success. One other issue, I had, was that I did not want to Error Handler of the package to kick off in case of this task failure. Also, since the task was in a Sequence Container, it was causing the Sequence Container execution results to be Failure thus invoking the "On Failure" workflow. &lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 10pt;"&gt;&lt;SPAN style="COLOR:#1f497d;mso-themecolor:text2;"&gt;&lt;FONT face=Calibri size=3&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 10pt;"&gt;&lt;SPAN style="COLOR:#1f497d;mso-themecolor:text2;"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;IMG title="Default behavior" style="WIDTH:267px;HEIGHT:413px;" height=413 alt="Default behavior" src="http://www.sqlservercommunity.org/img/blogImages/CFimg1.jpg" width=267 align=middle&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 10pt;"&gt;&lt;SPAN style="COLOR:#1f497d;mso-themecolor:text2;mso-no-proof:yes;"&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR:#1f497d;mso-themecolor:text2;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 10pt;"&gt;&lt;SPAN style="COLOR:#1f497d;mso-themecolor:text2;"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;This is the default behavior where the task failure for the “Drop active jobs partition” SSAS DDL task invokes the error handler at the package level (which is where I have a global error handler) and invokes a failure of its parent container. Since I know that this task is bound to fail the 1&lt;SUP&gt;st&lt;/SUP&gt; of every month (In this scenario, I am dropping, creating and processing a monthly SSAS partition on a daily which won’t exist on the 1&lt;SUP&gt;st&lt;/SUP&gt; of a given month), I want to gracefully “ignore” this failure and not signify a failure or write error rows in my error log tables. So, the way to handle this scenario was..&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoListParagraph style="MARGIN:0in 0in 10pt 0.5in;TEXT-INDENT:-0.25in;mso-list:l0 level1 lfo1;"&gt;&lt;SPAN style="COLOR:#1f497d;mso-themecolor:text2;mso-bidi-font-family:Calibri;mso-bidi-theme-font:minor-latin;"&gt;&lt;SPAN style="mso-list:Ignore;"&gt;&lt;FONT face=Calibri size=3&gt;1.&lt;/FONT&gt;&lt;SPAN style="FONT:7pt 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR:#1f497d;mso-themecolor:text2;"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Create an “On Error” Event Handler on the task “Drop active jobs partition” – You can leave the event handler blank with no tasks&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoListParagraph style="MARGIN:0in 0in 10pt 0.5in;TEXT-INDENT:-0.25in;mso-list:l0 level1 lfo1;"&gt;&lt;SPAN style="COLOR:#1f497d;mso-themecolor:text2;"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;o:p&gt;&lt;IMG title="On Error Event Handler" style="WIDTH:475px;HEIGHT:51px;" height=51 alt="On Error Event Handler" src="http://www.sqlservercommunity.org/img/blogImages/CFimg2.jpg" width=475 align=middle&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 10pt;"&gt;&lt;SPAN style="COLOR:#1f497d;mso-themecolor:text2;mso-no-proof:yes;"&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR:#1f497d;mso-themecolor:text2;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoListParagraph style="MARGIN:0in 0in 10pt 0.5in;TEXT-INDENT:-0.25in;mso-list:l0 level1 lfo1;"&gt;&lt;SPAN style="COLOR:#1f497d;mso-themecolor:text2;mso-bidi-font-family:Calibri;mso-bidi-theme-font:minor-latin;"&gt;&lt;SPAN style="mso-list:Ignore;"&gt;&lt;FONT face=Calibri size=3&gt;2.&lt;/FONT&gt;&lt;SPAN style="FONT:7pt 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR:#1f497d;mso-themecolor:text2;"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;To Prevent the error from going further up the chain, open up the System Variables from within the On Error error handler of the task and change the &lt;B style="mso-bidi-font-weight:normal;"&gt;Propogate&lt;/B&gt; property’s value to &lt;I style="mso-bidi-font-style:normal;"&gt;False&lt;/I&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoListParagraph style="MARGIN:0in 0in 10pt 0.5in;TEXT-INDENT:-0.25in;mso-list:l0 level1 lfo1;"&gt;&lt;SPAN style="COLOR:#1f497d;mso-themecolor:text2;"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;IMG title="Propogate Property" style="WIDTH:392px;HEIGHT:44px;" height=44 alt="Propogate Property" src="http://www.sqlservercommunity.org/img/blogImages/CFimg3.jpg" width=392 align=middle&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 10pt;"&gt;&lt;SPAN style="COLOR:#1f497d;mso-themecolor:text2;mso-no-proof:yes;"&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR:#1f497d;mso-themecolor:text2;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 10pt;"&gt;&lt;SPAN style="COLOR:#1f497d;mso-themecolor:text2;"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;This should provide the desired result where the error is contained within the task&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 10pt;"&gt;&lt;SPAN style="COLOR:#1f497d;mso-themecolor:text2;"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;IMG title=Result style="WIDTH:306px;HEIGHT:473px;" height=473 alt=Result src="http://www.sqlservercommunity.org/img/blogImages/CFimg4.jpg" width=306&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 10pt;"&gt;&lt;SPAN style="COLOR:#1f497d;mso-themecolor:text2;mso-no-proof:yes;"&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR:#1f497d;mso-themecolor:text2;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 10pt;"&gt;&lt;SPAN style="COLOR:#1f497d;mso-themecolor:text2;"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Optionally, you can also choose to set the &lt;B style="mso-bidi-font-weight:normal;"&gt;ForceExecutionResult&lt;/B&gt; property of this task to be &lt;I style="mso-bidi-font-style:normal;"&gt;Success&lt;/I&gt; so that it always signals a success – Even with this, you still need to follow the above steps to prevent errors from bubbling up in the package. &lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=6378" width="1" height="1"&gt;</description><category domain="http://sqlblog.com/blogs/rushabh_mehta/archive/tags/SSIS/default.aspx">SSIS</category><category domain="http://sqlblog.com/blogs/rushabh_mehta/archive/tags/Propogate/default.aspx">Propogate</category><category domain="http://sqlblog.com/blogs/rushabh_mehta/archive/tags/Error+Handling/default.aspx">Error Handling</category><category domain="http://sqlblog.com/blogs/rushabh_mehta/archive/tags/Event+Handler/default.aspx">Event Handler</category></item></channel></rss>