<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:copyright="http://blogs.law.harvard.edu/tech/rss" xmlns:image="http://purl.org/rss/1.0/modules/image/">
    <channel>
        <title>SQL Server</title>
        <link>http://geekswithblogs.net/LifeLongTechie/category/11148.aspx</link>
        <description>SQL Server</description>
        <language>en-US</language>
        <copyright>Kevin Shyr</copyright>
        <managingEditor>kevinshyr@gmail.com</managingEditor>
        <generator>Subtext Version 0.0.0.0</generator>
        <item>
            <title>Monitoring BizTalk Server Without SCCM, using SQL query</title>
            <link>http://geekswithblogs.net/LifeLongTechie/archive/2011/09/14/monitoring-biztalk-server-without-sccm-using-sql-query.aspx</link>
            <description>&lt;p&gt;For the environment that does not have SCCM to monitor BizTalk server health, the following SQL query can be incorporate into a SQL job and have BizTalk server at least on a "constant" check.&lt;/p&gt;
&lt;p&gt;Note: be aware that the following was tested only against a single suspended instance with a send port.  Since BizTalk SQL server does not allow select against the ServiceClass table, I couldn't use a single table join.  With the data I currently have, I am not 100% sure the Receive Port, Pipeline, Orchestration parts work.&lt;/p&gt;
&lt;div style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&amp;#xD;&amp;#xA;normal;text-autospace:none"&gt; &lt;/div&gt;
&lt;div style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&amp;#xD;&amp;#xA;normal;text-autospace:none"&gt;&lt;span style="font-size:&amp;#xD;&amp;#xA;10.0pt;Courier New&amp;quot;;color:blue;"&gt;SELECT&lt;/span&gt;&lt;span style="font-size:10.0pt;Courier New&amp;quot;;"&gt; &lt;span style="color:blue"&gt;TOP&lt;/span&gt; 1000 &lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&amp;#xD;&amp;#xA;normal;text-autospace:none"&gt;&lt;span style="font-size:&amp;#xD;&amp;#xA;10.0pt;Courier New&amp;quot;;"&gt;      _M&lt;span style="color:gray"&gt;.&lt;/span&gt;nvcName &lt;span style="color:blue"&gt;AS&lt;/span&gt; ApplicationName&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&amp;#xD;&amp;#xA;normal;text-autospace:none"&gt;&lt;span style="font-size:&amp;#xD;&amp;#xA;10.0pt;Courier New&amp;quot;;"&gt;      &lt;span style="color:gray"&gt;,&lt;/span&gt; &lt;span style="color:blue"&gt;CASE&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&amp;#xD;&amp;#xA;normal;text-autospace:none"&gt;&lt;span style="font-size:&amp;#xD;&amp;#xA;10.0pt;Courier New&amp;quot;;"&gt;            &lt;span style="color:blue"&gt;WHEN&lt;/span&gt; _BSP&lt;span style="color:gray"&gt;.&lt;/span&gt;nvcName &lt;span style="color:gray"&gt;IS&lt;/span&gt; &lt;span style="color:gray"&gt;NOT&lt;/span&gt; &lt;span style="color:gray"&gt;NULL&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&amp;#xD;&amp;#xA;normal;text-autospace:none"&gt;&lt;span style="font-size:&amp;#xD;&amp;#xA;10.0pt;Courier New&amp;quot;;"&gt;                  &lt;span style="color:blue"&gt;THEN&lt;/span&gt; &lt;span style="color:red"&gt;'Send Port: '&lt;/span&gt; &lt;span style="color:gray"&gt;+&lt;/span&gt; _BSP&lt;span style="color:gray"&gt;.&lt;/span&gt;nvcName&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&amp;#xD;&amp;#xA;normal;text-autospace:none"&gt;&lt;span style="font-size:&amp;#xD;&amp;#xA;10.0pt;Courier New&amp;quot;;"&gt;            &lt;span style="color:blue"&gt;WHEN&lt;/span&gt; _BSP&lt;span style="color:gray"&gt;.&lt;/span&gt;nvcName &lt;span style="color:gray"&gt;IS&lt;/span&gt; &lt;span style="color:gray"&gt;NOT&lt;/span&gt; &lt;span style="color:gray"&gt;NULL&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&amp;#xD;&amp;#xA;normal;text-autospace:none"&gt;&lt;span style="font-size:&amp;#xD;&amp;#xA;10.0pt;Courier New&amp;quot;;"&gt;                  &lt;span style="color:blue"&gt;THEN&lt;/span&gt; &lt;span style="color:red"&gt;'Receive Port: '&lt;/span&gt; &lt;span style="color:gray"&gt;+&lt;/span&gt; _BSP&lt;span style="color:gray"&gt;.&lt;/span&gt;nvcName&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&amp;#xD;&amp;#xA;normal;text-autospace:none"&gt;&lt;span style="font-size:&amp;#xD;&amp;#xA;10.0pt;Courier New&amp;quot;;"&gt;            &lt;span style="color:blue"&gt;WHEN&lt;/span&gt; _BPL&lt;span style="color:gray"&gt;.&lt;/span&gt;Name &lt;span style="color:gray"&gt;IS&lt;/span&gt; &lt;span style="color:gray"&gt;NOT&lt;/span&gt; &lt;span style="color:gray"&gt;NULL&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&amp;#xD;&amp;#xA;normal;text-autospace:none"&gt;&lt;span style="font-size:&amp;#xD;&amp;#xA;10.0pt;Courier New&amp;quot;;"&gt;                  &lt;span style="color:blue"&gt;THEN&lt;/span&gt; &lt;span style="color:red"&gt;'Pipeline: '&lt;/span&gt; &lt;span style="color:gray"&gt;+&lt;/span&gt; _BPL&lt;span style="color:gray"&gt;.&lt;/span&gt;Name&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&amp;#xD;&amp;#xA;normal;text-autospace:none"&gt;&lt;span style="font-size:&amp;#xD;&amp;#xA;10.0pt;Courier New&amp;quot;;"&gt;            &lt;span style="color:blue"&gt;WHEN&lt;/span&gt; _BO&lt;span style="color:gray"&gt;.&lt;/span&gt;nvcName &lt;span style="color:gray"&gt;IS&lt;/span&gt; &lt;span style="color:gray"&gt;NOT&lt;/span&gt; &lt;span style="color:gray"&gt;NULL&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&amp;#xD;&amp;#xA;normal;text-autospace:none"&gt;&lt;span style="font-size:&amp;#xD;&amp;#xA;10.0pt;Courier New&amp;quot;;"&gt;                  &lt;span style="color:blue"&gt;THEN&lt;/span&gt; &lt;span style="color:red"&gt;'Orchestration: '&lt;/span&gt; &lt;span style="color:gray"&gt;+&lt;/span&gt; _BO&lt;span style="color:gray"&gt;.&lt;/span&gt;nvcName&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&amp;#xD;&amp;#xA;normal;text-autospace:none"&gt;&lt;span style="font-size:&amp;#xD;&amp;#xA;10.0pt;Courier New&amp;quot;;"&gt;            &lt;span style="color:blue"&gt;ELSE&lt;/span&gt; &lt;span style="color:red"&gt;'Unknown'&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&amp;#xD;&amp;#xA;normal;text-autospace:none"&gt;&lt;span style="font-size:&amp;#xD;&amp;#xA;10.0pt;Courier New&amp;quot;;"&gt;      &lt;span style="color:blue"&gt;END&lt;/span&gt; &lt;span style="color:blue"&gt;AS&lt;/span&gt; ServiceName&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&amp;#xD;&amp;#xA;normal;text-autospace:none"&gt;&lt;span style="font-size:&amp;#xD;&amp;#xA;10.0pt;Courier New&amp;quot;;"&gt;      &lt;span style="color:gray"&gt;,&lt;/span&gt; _IS&lt;span style="color:gray"&gt;.&lt;/span&gt;dtCreated&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&amp;#xD;&amp;#xA;normal;text-autospace:none"&gt;&lt;span style="font-size:&amp;#xD;&amp;#xA;10.0pt;Courier New&amp;quot;;"&gt;      &lt;span style="color:gray"&gt;,&lt;/span&gt; _IS&lt;span style="color:gray"&gt;.&lt;/span&gt;dtSuspendTimeStamp&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&amp;#xD;&amp;#xA;normal;text-autospace:none"&gt;&lt;span style="font-size:&amp;#xD;&amp;#xA;10.0pt;Courier New&amp;quot;;"&gt;      &lt;span style="color:gray"&gt;,&lt;/span&gt; _IS&lt;span style="color:gray"&gt;.&lt;/span&gt;nvcAdapter&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&amp;#xD;&amp;#xA;normal;text-autospace:none"&gt;&lt;span style="font-size:&amp;#xD;&amp;#xA;10.0pt;Courier New&amp;quot;;"&gt;      &lt;span style="color:gray"&gt;,&lt;/span&gt; _IS&lt;span style="color:gray"&gt;.&lt;/span&gt;nvcURI&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&amp;#xD;&amp;#xA;normal;text-autospace:none"&gt;&lt;span style="font-size:&amp;#xD;&amp;#xA;10.0pt;Courier New&amp;quot;;"&gt;      &lt;span style="color:gray"&gt;,&lt;/span&gt; _IS&lt;span style="color:gray"&gt;.&lt;/span&gt;nvcErrorDescription&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&amp;#xD;&amp;#xA;normal;text-autospace:none"&gt;&lt;span style="font-size:&amp;#xD;&amp;#xA;10.0pt;Courier New&amp;quot;;"&gt;      &lt;span style="color:gray"&gt;,&lt;/span&gt; _IS&lt;span style="color:gray"&gt;.&lt;/span&gt;nvcErrorProcessingServer&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&amp;#xD;&amp;#xA;normal;text-autospace:none"&gt;&lt;span style="font-size:&amp;#xD;&amp;#xA;10.0pt;Courier New&amp;quot;;color:blue;"&gt;FROM&lt;/span&gt;&lt;span style="font-size:10.0pt;Courier New&amp;quot;;"&gt; [BizTalkMsgBoxDb]&lt;span style="color:gray"&gt;.&lt;/span&gt;[dbo]&lt;span style="color:gray"&gt;.&lt;/span&gt;[InstancesSuspended] &lt;span style="color:blue"&gt;AS&lt;/span&gt; _IS &lt;span style="color:blue"&gt;WITH&lt;/span&gt;&lt;span style="color:gray"&gt;(&lt;/span&gt;&lt;span style="color:blue"&gt;READPAST&lt;/span&gt;&lt;span style="color:gray"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&amp;#xD;&amp;#xA;normal;text-autospace:none"&gt;&lt;span style="font-size:&amp;#xD;&amp;#xA;10.0pt;Courier New&amp;quot;;"&gt;      &lt;span style="color:gray"&gt;INNER&lt;/span&gt; &lt;span style="color:gray"&gt;JOIN&lt;/span&gt; [BizTalkMsgBoxDb]&lt;span style="color:gray"&gt;.&lt;/span&gt;[dbo]&lt;span style="color:gray"&gt;.&lt;/span&gt;[Services] &lt;span style="color:blue"&gt;AS&lt;/span&gt; _S &lt;span style="color:blue"&gt;WITH&lt;/span&gt;&lt;span style="color:gray"&gt;(&lt;/span&gt;&lt;span style="color:blue"&gt;READPAST&lt;/span&gt;&lt;span style="color:gray"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&amp;#xD;&amp;#xA;normal;text-autospace:none"&gt;&lt;span style="font-size:&amp;#xD;&amp;#xA;10.0pt;Courier New&amp;quot;;"&gt;            &lt;span style="color:blue"&gt;ON&lt;/span&gt; _IS&lt;span style="color:gray"&gt;.&lt;/span&gt;[uidServiceID] &lt;span style="color:gray"&gt;=&lt;/span&gt; _S&lt;span style="color:gray"&gt;.&lt;/span&gt;uidServiceID&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&amp;#xD;&amp;#xA;normal;text-autospace:none"&gt;&lt;span style="font-size:&amp;#xD;&amp;#xA;10.0pt;Courier New&amp;quot;;"&gt;      &lt;span style="color:gray"&gt;INNER&lt;/span&gt; &lt;span style="color:gray"&gt;JOIN&lt;/span&gt; [BizTalkMsgBoxDb]&lt;span style="color:gray"&gt;.&lt;/span&gt;[dbo]&lt;span style="color:gray"&gt;.&lt;/span&gt;[Modules] &lt;span style="color:blue"&gt;AS&lt;/span&gt; _M &lt;span style="color:blue"&gt;WITH&lt;/span&gt;&lt;span style="color:gray"&gt;(&lt;/span&gt;&lt;span style="color:blue"&gt;READPAST&lt;/span&gt;&lt;span style="color:gray"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&amp;#xD;&amp;#xA;normal;text-autospace:none"&gt;&lt;span style="font-size:&amp;#xD;&amp;#xA;10.0pt;Courier New&amp;quot;;"&gt;            &lt;span style="color:blue"&gt;ON&lt;/span&gt; _S&lt;span style="color:gray"&gt;.&lt;/span&gt;nModuleID &lt;span style="color:gray"&gt;=&lt;/span&gt; _M&lt;span style="color:gray"&gt;.&lt;/span&gt;nModuleID&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&amp;#xD;&amp;#xA;normal;text-autospace:none"&gt;&lt;span style="font-size:&amp;#xD;&amp;#xA;10.0pt;Courier New&amp;quot;;"&gt;      &lt;span style="color:gray"&gt;LEFT&lt;/span&gt; &lt;span style="color:gray"&gt;OUTER&lt;/span&gt; &lt;span style="color:gray"&gt;JOIN&lt;/span&gt; [BizTalkMgmtDb]&lt;span style="color:gray"&gt;.&lt;/span&gt;[dbo]&lt;span style="color:gray"&gt;.&lt;/span&gt;[bts_sendport] &lt;span style="color:blue"&gt;AS&lt;/span&gt; _BSP &lt;span style="color:blue"&gt;WITH&lt;/span&gt;&lt;span style="color:gray"&gt;(&lt;/span&gt;&lt;span style="color:blue"&gt;READPAST&lt;/span&gt;&lt;span style="color:gray"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&amp;#xD;&amp;#xA;normal;text-autospace:none"&gt;&lt;span style="font-size:&amp;#xD;&amp;#xA;10.0pt;Courier New&amp;quot;;"&gt;            &lt;span style="color:blue"&gt;ON&lt;/span&gt; _IS&lt;span style="color:gray"&gt;.&lt;/span&gt;uidServiceID &lt;span style="color:gray"&gt;=&lt;/span&gt; _BSP&lt;span style="color:gray"&gt;.&lt;/span&gt;uidGUID&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&amp;#xD;&amp;#xA;normal;text-autospace:none"&gt;&lt;span style="font-size:&amp;#xD;&amp;#xA;10.0pt;Courier New&amp;quot;;"&gt;      &lt;span style="color:gray"&gt;LEFT&lt;/span&gt; &lt;span style="color:gray"&gt;OUTER&lt;/span&gt; &lt;span style="color:gray"&gt;JOIN&lt;/span&gt; [BizTalkMgmtDb]&lt;span style="color:gray"&gt;.&lt;/span&gt;[dbo]&lt;span style="color:gray"&gt;.&lt;/span&gt;[bts_receiveport] &lt;span style="color:blue"&gt;AS&lt;/span&gt; _BRP &lt;span style="color:blue"&gt;WITH&lt;/span&gt;&lt;span style="color:gray"&gt;(&lt;/span&gt;&lt;span style="color:blue"&gt;READPAST&lt;/span&gt;&lt;span style="color:gray"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&amp;#xD;&amp;#xA;normal;text-autospace:none"&gt;&lt;span style="font-size:&amp;#xD;&amp;#xA;10.0pt;Courier New&amp;quot;;"&gt;            &lt;span style="color:blue"&gt;ON&lt;/span&gt; _IS&lt;span style="color:gray"&gt;.&lt;/span&gt;uidServiceID &lt;span style="color:gray"&gt;=&lt;/span&gt; _BRP&lt;span style="color:gray"&gt;.&lt;/span&gt;uidGUID&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&amp;#xD;&amp;#xA;normal;text-autospace:none"&gt;&lt;span style="font-size:&amp;#xD;&amp;#xA;10.0pt;Courier New&amp;quot;;"&gt;      &lt;span style="color:gray"&gt;LEFT&lt;/span&gt; &lt;span style="color:gray"&gt;OUTER&lt;/span&gt; &lt;span style="color:gray"&gt;JOIN&lt;/span&gt; [BizTalkMgmtDb]&lt;span style="color:gray"&gt;.&lt;/span&gt;[dbo]&lt;span style="color:gray"&gt;.&lt;/span&gt;[bts_pipeline] &lt;span style="color:blue"&gt;AS&lt;/span&gt; _BPL &lt;span style="color:blue"&gt;WITH&lt;/span&gt;&lt;span style="color:gray"&gt;(&lt;/span&gt;&lt;span style="color:blue"&gt;READPAST&lt;/span&gt;&lt;span style="color:gray"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&amp;#xD;&amp;#xA;normal;text-autospace:none"&gt;&lt;span style="font-size:&amp;#xD;&amp;#xA;10.0pt;Courier New&amp;quot;;"&gt;            &lt;span style="color:blue"&gt;ON&lt;/span&gt; _IS&lt;span style="color:gray"&gt;.&lt;/span&gt;uidServiceID &lt;span style="color:gray"&gt;=&lt;/span&gt; _BPL&lt;span style="color:gray"&gt;.&lt;/span&gt;PipelineID&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&amp;#xD;&amp;#xA;normal;text-autospace:none"&gt;&lt;span style="font-size:&amp;#xD;&amp;#xA;10.0pt;Courier New&amp;quot;;"&gt;      &lt;span style="color:gray"&gt;LEFT&lt;/span&gt; &lt;span style="color:gray"&gt;OUTER&lt;/span&gt; &lt;span style="color:gray"&gt;JOIN&lt;/span&gt; [BizTalkMgmtDb]&lt;span style="color:gray"&gt;.&lt;/span&gt;[dbo]&lt;span style="color:gray"&gt;.&lt;/span&gt;[bts_orchestration] &lt;span style="color:blue"&gt;AS&lt;/span&gt; _BO &lt;span style="color:blue"&gt;WITH&lt;/span&gt;&lt;span style="color:gray"&gt;(&lt;/span&gt;&lt;span style="color:blue"&gt;READPAST&lt;/span&gt;&lt;span style="color:gray"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&amp;#xD;&amp;#xA;normal;text-autospace:none"&gt;&lt;span style="font-size:&amp;#xD;&amp;#xA;10.0pt;Courier New&amp;quot;;"&gt;            &lt;span style="color:blue"&gt;ON&lt;/span&gt; _IS&lt;span style="color:gray"&gt;.&lt;/span&gt;uidServiceID &lt;span style="color:gray"&gt;=&lt;/span&gt; _BO&lt;span style="color:gray"&gt;.&lt;/span&gt;uidGUID&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&amp;#xD;&amp;#xA;normal;text-autospace:none"&gt;&lt;span style="font-size:&amp;#xD;&amp;#xA;10.0pt;Courier New&amp;quot;;color:blue;"&gt;WHERE&lt;/span&gt;&lt;/div&gt;
&lt;div style="margin-bottom:0in;margin-bottom:.0001pt;line-height:&amp;#xD;&amp;#xA;normal;text-autospace:none"&gt;&lt;span style="font-size:&amp;#xD;&amp;#xA;10.0pt;Courier New&amp;quot;;"&gt;      _M&lt;span style="color:gray"&gt;.&lt;/span&gt;nvcName &lt;span style="color:gray"&gt;=&lt;/span&gt; &lt;span style="color:red"&gt;'Your application name'&lt;/span&gt; &lt;span style="color:green"&gt;-- change application name here to monitor different applications&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;p&gt; &lt;/p&gt; &lt;img src="http://geekswithblogs.net/LifeLongTechie/aggbug/146891.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Kevin Shyr</dc:creator>
            <guid>http://geekswithblogs.net/LifeLongTechie/archive/2011/09/14/monitoring-biztalk-server-without-sccm-using-sql-query.aspx</guid>
            <pubDate>Thu, 15 Sep 2011 03:37:04 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/LifeLongTechie/comments/146891.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/LifeLongTechie/archive/2011/09/14/monitoring-biztalk-server-without-sccm-using-sql-query.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/LifeLongTechie/comments/commentRss/146891.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/LifeLongTechie/services/trackbacks/146891.aspx</trackback:ping>
        </item>
        <item>
            <title>Do NOT trust CHECKSUM or BINARY_CHECKSUM in SQL, use HASHBYTES instead</title>
            <link>http://geekswithblogs.net/LifeLongTechie/archive/2011/05/20/do-not-trust-checksum-or-binary_checksum-in-sql-use-hashbytes.aspx</link>
            <description>&lt;p&gt;We had a process ot using BizTalk to take in a reference file, then send data in via a table_type parameter in a stored procedure.  The stored procedure uses a MERGE statement to insert and update; the update part of which does a CHECKSUM first to determine whether an update is even necessary.&lt;/p&gt;
&lt;p&gt;Then it happened, we had a reference row that should have been updated by the latest file, but it wasn't done.  We checked the incoming and outgoing BizTalk Message in and out of the pipeline; everything looked normal.  Then we decided to take out the CHECKSUM part and the update succeeded.&lt;/p&gt;
&lt;p&gt;In reading over the Microsoft documentation, I was absolutely shocked when I read this in the remarks section:&lt;/p&gt;
&lt;p style="margin-left: 40px;"&gt;&lt;em&gt;However, there is a small chance that the checksum will not change. For this reason, we do not recommend using CHECKSUM to detect whether values have changed, unless your application can tolerate occasionally missing a change&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/ms189788%28v=SQL.100%29.aspx"&gt;http://msdn.microsoft.com/en-us/library/ms189788%28v=SQL.100%29.aspx&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Then I checked the page for BINARY_CHECKSUM, a similar remark exists.  &lt;a href="http://msdn.microsoft.com/en-us/library/ms173784%28v=SQL.100%29.aspx"&gt;http://msdn.microsoft.com/en-us/library/ms173784%28v=SQL.100%29.aspx&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;According to these 2 articles, we should be using HASHBYTES().  &lt;a href="http://msdn.microsoft.com/en-us/library/ms174415%28v=SQL.100%29.aspx"&gt;http://msdn.microsoft.com/en-us/library/ms174415%28v=SQL.100%29.aspx&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Personally, I was really shocked to find a function in any database that "most of the time" does its job.  I really do not know any system that tolerates "occasional" mistakes, or maybe it's that I haven't worked in enough industries.  I equate this to getting a notice on your bank statement saying "we might not have all your transaction listed, and we don't know for sure whether we have them all".&lt;/p&gt;
&lt;p&gt;I love quantum physics, but not in my computer systems.&lt;/p&gt; &lt;img src="http://geekswithblogs.net/LifeLongTechie/aggbug/145470.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Kevin Shyr</dc:creator>
            <guid>http://geekswithblogs.net/LifeLongTechie/archive/2011/05/20/do-not-trust-checksum-or-binary_checksum-in-sql-use-hashbytes.aspx</guid>
            <pubDate>Sat, 21 May 2011 01:50:01 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/LifeLongTechie/comments/145470.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/LifeLongTechie/archive/2011/05/20/do-not-trust-checksum-or-binary_checksum-in-sql-use-hashbytes.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/LifeLongTechie/comments/commentRss/145470.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/LifeLongTechie/services/trackbacks/145470.aspx</trackback:ping>
        </item>
        <item>
            <title>Frustration and rewards on using SSIS Pivot and Unpivot</title>
            <link>http://geekswithblogs.net/LifeLongTechie/archive/2011/05/20/frustration-and-rewards-on-using-ssis-pivot-and-unpivot.aspx</link>
            <description>&lt;p&gt;Granted, if you are just transforming data in the same SQL server, why would you do it in SSIS instead of just using Pivot and Unpivot in T-SQL query?  But what about in the case where data comes from various sources?&lt;/p&gt;
&lt;p&gt;What I had fun doing was the ability to skip using Linked server, pull in data from different sources, like XML over web service.  Another point that made me happy was the ability to simulate ROW_NUMBER() function with the merged data by using a Script Component.&lt;/p&gt;
&lt;p&gt;Anyway, I highly recommend everyone to try this out.  It's very frustrating throughout the process, but the result is very rewarding.  &lt;img alt="" src="http://geekswithblogs.net/Providers/BlogEntryEditor/FCKeditor/editor/images/smiley/msn/regular_smile.gif" /&gt;&lt;/p&gt;
&lt;p&gt;Pivot:  &lt;a href="http://msdn.microsoft.com/en-us/library/ms140308.aspx"&gt;http://msdn.microsoft.com/en-us/library/ms140308.aspx&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;Unpivot:  &lt;a href="http://msdn.microsoft.com/en-us/library/ms141723.aspx"&gt;http://msdn.microsoft.com/en-us/library/ms141723.aspx&lt;/a&gt;&lt;/p&gt; &lt;img src="http://geekswithblogs.net/LifeLongTechie/aggbug/145464.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Kevin Shyr</dc:creator>
            <guid>http://geekswithblogs.net/LifeLongTechie/archive/2011/05/20/frustration-and-rewards-on-using-ssis-pivot-and-unpivot.aspx</guid>
            <pubDate>Fri, 20 May 2011 20:36:30 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/LifeLongTechie/comments/145464.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/LifeLongTechie/archive/2011/05/20/frustration-and-rewards-on-using-ssis-pivot-and-unpivot.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/LifeLongTechie/comments/commentRss/145464.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/LifeLongTechie/services/trackbacks/145464.aspx</trackback:ping>
        </item>
        <item>
            <title>Instead of alter table column to turn IDENTITY on and off, turn IDENTITY_INSERT on and off</title>
            <link>http://geekswithblogs.net/LifeLongTechie/archive/2011/03/02/instead-of-alter-table-column-to-turn-identity-on-and.aspx</link>
            <description>&lt;p&gt;First of all, I don't know which version of SQL this post (http://www.techonthenet.com/sql/tables/alter_table.php) is based on, but at least for Microsoft SQL Server 2008, the syntax is not:&lt;/p&gt;
&lt;p&gt;ALTER TABLE [table_name]&lt;br /&gt;
MODIFY [column_name] [data_type] NOT NULL;&lt;/p&gt;
&lt;p&gt;Instead, it should be:&lt;/p&gt;
&lt;p&gt;ALTER TABLE [table_name]&lt;br /&gt;
ALTER COLUMN [column_name] [data_type] NOT NULL;&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;Then, as several posts point out, you can't use T-SQL to run an existing column into an IDENTITY column.  Instead, use the IDENTITY_INSERT to copy data from other tables.  http://msdn.microsoft.com/en-us/library/ms188059.aspx&lt;/p&gt;
&lt;pre&gt;
SET IDENTITY_INSERT [table_name] ON
INSERT ....
SET IDENTITY_INSERT [table_name] OFF&lt;/pre&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;http://www.sqlservercentral.com/Forums/Topic126147-8-1.aspx&lt;/p&gt;
&lt;p&gt;http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=65257&lt;/p&gt; &lt;img src="http://geekswithblogs.net/LifeLongTechie/aggbug/144162.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Kevin Shyr</dc:creator>
            <guid>http://geekswithblogs.net/LifeLongTechie/archive/2011/03/02/instead-of-alter-table-column-to-turn-identity-on-and.aspx</guid>
            <pubDate>Thu, 03 Mar 2011 05:24:34 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/LifeLongTechie/comments/144162.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/LifeLongTechie/archive/2011/03/02/instead-of-alter-table-column-to-turn-identity-on-and.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/LifeLongTechie/comments/commentRss/144162.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/LifeLongTechie/services/trackbacks/144162.aspx</trackback:ping>
        </item>
        <item>
            <title>Using BizTalk to bridge SQL Job and Human Intervention (Requesting Permission)</title>
            <link>http://geekswithblogs.net/LifeLongTechie/archive/2011/02/04/using-biztalk-to-bridge-sql-job-and-human-intervention-requesting.aspx</link>
            <description>&lt;p&gt;I start off the process with either a BizTalk Scheduler (http://biztalkscheduledtask.codeplex.com/releases/view/50363) or a manual file drop of the XML message.  The manual file drop is to allow the SQL &lt;/p&gt;
&lt;p&gt;Job to call a "File Copy" SSIS step to copy the trigger file for the next process and allows SQL &lt;/p&gt;
&lt;p&gt;Job to be linked back into BizTalk processing.&lt;/p&gt;
&lt;p&gt;The Process Trigger XML looks like the following.  It is basically the configuration hub of the business process&lt;/p&gt;
&lt;p&gt;&amp;lt;ns0:MsgSchedulerTriggerSQLJobReceive xmlns:ns0="urn:com:something something"&amp;gt;&lt;br /&gt;
  &amp;lt;ns0:IsProcessAsync&amp;gt;YES&amp;lt;/ns0:IsProcessAsync&amp;gt;&lt;br /&gt;
  &amp;lt;ns0:IsPermissionRequired&amp;gt;YES&amp;lt;/ns0:IsPermissionRequired&amp;gt;&lt;br /&gt;
  &amp;lt;ns0:BusinessProcessName&amp;gt;Data Push&amp;lt;/ns0:BusinessProcessName&amp;gt; &lt;br /&gt;
  &amp;lt;ns0:EmailFrom&amp;gt;DoNotReply@company.com&amp;lt;/ns0:EmailFrom&amp;gt;&lt;br /&gt;
  &amp;lt;ns0:EmailRecipientToList&amp;gt;ProjectManagers@company.com&amp;lt;/ns0:EmailRecipientToList&amp;gt;&lt;br /&gt;
  &amp;lt;ns0:EmailRecipientCCList&amp;gt;Developers@company.com&amp;lt;/ns0:EmailRecipientCCList&amp;gt;&lt;br /&gt;
  &amp;lt;ns0:EmailMessageBodyForPermissionRequest&amp;gt;This message was sent to request permission to start the Data Push process.  The SQL Job to be run is WeeklyProcessing_DataPush&amp;lt;/ns0:EmailMessageBodyForPermissionRequest&amp;gt;&lt;br /&gt;
  &amp;lt;ns0:SQLJobName&amp;gt;WeeklyProcessing_DataPush&amp;lt;/ns0:SQLJobName&amp;gt;&lt;br /&gt;
  &amp;lt;ns0:SQLJobStepName&amp;gt;Push_To_Production&amp;lt;/ns0:SQLJobStepName&amp;gt;&lt;br /&gt;
  &amp;lt;ns0:SQLJobMinToWait&amp;gt;1&amp;lt;/ns0:SQLJobMinToWait&amp;gt;&lt;br /&gt;
  &amp;lt;ns0:PermissionRequestTriggerPath&amp;gt;\\server\ETL-BizTalk\Automation\TriggerCreatedByBizTalk\&amp;lt;/ns0:PermissionRequestTriggerPath&amp;gt;&lt;br /&gt;
  &amp;lt;ns0:PermissionRequestApprovedPath&amp;gt;\\server\ETL-BizTalk\Automation\Approved\&amp;lt;/ns0:PermissionRequestApprovedPath&amp;gt;&lt;br /&gt;
  &amp;lt;ns0:PermissionRequestNotApprovedPath&amp;gt;\\server\ETL-BizTalk\Automation\NotApproved\&amp;lt;/ns0:PermissionRequestNotApprovedPath&amp;gt;&lt;br /&gt;
&amp;lt;/ns0:MsgSchedulerTriggerSQLJobReceive&amp;gt;&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;Every node of this schema was promoted to a distinguished field so that the values can be used for decision making in the orchestration.  The first decision made is on the "IsPermissionRequired" field.&lt;/p&gt;
&lt;p&gt;&lt;img height="256" width="640" src="/images/geekswithblogs_net/LifeLongTechie/10637/r_BizTalk-SQLJob-Permission_Linking_OrchestrationStart.JPG" alt="" /&gt;&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;If permission is required (IsPermissionRequired=="YES"), BizTalk will use the configuration info in the XML trigger to format the email message.  Here is the snippet of how the email message is constructed.&lt;/p&gt;
&lt;p&gt;SQLJobEmailMessage.EmailBody &lt;br /&gt;
    = new Eai.OrchestrationHelpers.XlangCustomFormatters.RawString(&lt;br /&gt;
        MsgSchedulerTriggerSQLJobReceive.EmailMessageBodyForPermissionRequest + &lt;br /&gt;
        "&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;" +&lt;br /&gt;
        "By moving the file, you are either giving permission to the process, or disapprove of the process." +&lt;br /&gt;
        "&amp;lt;br&amp;gt;" +&lt;br /&gt;
        "This is the file to move: \"" + PermissionTriggerToBeGenereatedHere +&lt;br /&gt;
        "\"&amp;lt;br&amp;gt;" +&lt;br /&gt;
        "(You may find it easier to open the destination folder first, then navigate to the sibling folder to get to this file)" +&lt;br /&gt;
        "&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;" +&lt;br /&gt;
        "To approve, move(NOT copy) the file here: " + MsgSchedulerTriggerSQLJobReceive.PermissionRequestApprovedPath +&lt;br /&gt;
        "&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;" + &lt;br /&gt;
        "To disapprove, move(NOT copy) the file here: " + MsgSchedulerTriggerSQLJobReceive.PermissionRequestNotApprovedPath +&lt;br /&gt;
        "&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;" + &lt;br /&gt;
        "The file will be IMMEDIATELY picked up by the automated process.  This is normal.  You should receive a message soon that the file is processed." +&lt;br /&gt;
        "&amp;lt;br&amp;gt;" + &lt;br /&gt;
        "Thank you!"&lt;br /&gt;
    );&lt;br /&gt;
SQLJobSendNotification(Microsoft.XLANGs.BaseTypes.Address) = "mailto:" + MsgSchedulerTriggerSQLJobReceive.EmailRecipientToList;&lt;br /&gt;
SQLJobEmailMessage.EmailBody(Microsoft.XLANGs.BaseTypes.ContentType) = "text/html";&lt;br /&gt;
SQLJobEmailMessage(SMTP.Subject) = "Requesting Permission to Start the " + MsgSchedulerTriggerSQLJobReceive.BusinessProcessName;&lt;br /&gt;
SQLJobEmailMessage(SMTP.From) = MsgSchedulerTriggerSQLJobReceive.EmailFrom;&lt;br /&gt;
SQLJobEmailMessage(SMTP.CC) = MsgSchedulerTriggerSQLJobReceive.EmailRecipientCCList;&lt;br /&gt;
SQLJobEmailMessage(SMTP.EmailBodyFileCharset) = "UTF-8";&lt;br /&gt;
SQLJobEmailMessage(SMTP.SMTPHost) = "localhost";&lt;br /&gt;
SQLJobEmailMessage(SMTP.MessagePartsAttachments) = 2;&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;After the Permission request email is sent, the next step is to generate the actual Permission Trigger file.  A correlation set is used here on SQLJobName and a newly generated GUID field.&lt;/p&gt;
&lt;p&gt;&amp;lt;?xml version="1.0" encoding="utf-8"?&amp;gt;&amp;lt;ns0:SQLJobAuthorizationTrigger xmlns:ns0="somethingsomething"&amp;gt;&amp;lt;SQLJobName&amp;gt;Data Push&amp;lt;/SQLJobName&amp;gt;&amp;lt;CorrelationGuid&amp;gt;9f7c6b46-0e62-46a7-b3a0-b5327ab03753&amp;lt;/CorrelationGuid&amp;gt;&amp;lt;/ns0:SQLJobAuthorizationTrigger&amp;gt;&lt;/p&gt;
&lt;p&gt;The end user (the human intervention piece) will either grant permission for this process, or deny it, by moving the Permission Trigger file to either the "Approved" folder or the "NotApproved" folder.  A parallel Listen shape is waiting for either response.&lt;/p&gt;
&lt;p&gt;&lt;img height="480" width="604" src="/images/geekswithblogs_net/LifeLongTechie/10637/r_BizTalk-SQLJob-Permission_Linking_EmailPermissionRequestAndApprovalProcess.JPG" alt="" /&gt;&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;The next set of steps decide how the SQL Job is to be called, or whether it is called at all.  If permission denied, it simply sends out a notification.  If permission is granted, then the flag (IsProcessAsync) in the original Process Trigger is used.  The synchonous part is not really synchronous, but a loop timer to check the status within the calling stored procedure (for more information, check out my previous post:  http://geekswithblogs.net/LifeLongTechie/archive/2010/11/01/execute-sql-job-synchronously-for-biztalk-via-a-stored-procedure.aspx)  If it's async, then the sp starts the job and BizTalk sends out an email.&lt;/p&gt;
&lt;p&gt;&lt;img height="480" width="581" src="/images/geekswithblogs_net/LifeLongTechie/10637/r_BizTalk-SQLJob-Permission_Linking_StartSQLJob.JPG" alt="" /&gt;&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;And of course, some error notification:&lt;/p&gt;
&lt;p&gt;&lt;img height="480" width="546" src="/images/geekswithblogs_net/LifeLongTechie/10637/r_BizTalk-SQLJob-Permission_Linking_ExceptionHandling.JPG" alt="" /&gt;&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;Footnote: The next version of this orchestration will have an additional parallel line near the Listen shape with a Delay built in and a Loop to send out a daily reminder if no response has been received from the end user.  The synchronous part is used to gather results and execute a data clean up process so that the SQL Job can be re-tried.  There are manu possibilities here.&lt;/p&gt; &lt;img src="http://geekswithblogs.net/LifeLongTechie/aggbug/143807.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Kevin Shyr</dc:creator>
            <guid>http://geekswithblogs.net/LifeLongTechie/archive/2011/02/04/using-biztalk-to-bridge-sql-job-and-human-intervention-requesting.aspx</guid>
            <pubDate>Fri, 04 Feb 2011 21:29:09 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/LifeLongTechie/comments/143807.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/LifeLongTechie/archive/2011/02/04/using-biztalk-to-bridge-sql-job-and-human-intervention-requesting.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/LifeLongTechie/comments/commentRss/143807.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/LifeLongTechie/services/trackbacks/143807.aspx</trackback:ping>
        </item>
        <item>
            <title>Using SSIS to send a HTML E-Mail Message with built-in table of Counts.</title>
            <link>http://geekswithblogs.net/LifeLongTechie/archive/2011/02/02/using-ssis-to-send-a-html-e-mail-message-with-built-in.aspx</link>
            <description>&lt;p&gt;For the record, this can be just as easily done with a .NET class with a DLL call.  The two major reasons for this ending up as a SSIS package are:&lt;/p&gt;
&lt;ul&gt;
    &lt;li&gt;There are a lot of SQL resources in the organization for maintenance, but not as many .NET developers.&lt;/li&gt;
    &lt;li&gt;There is an existing automated process that links up SQL Jobs (more on that in the next post), and this is part of that process.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;To start, this is what the SSIS looks like:&lt;/p&gt;
&lt;p&gt;&lt;img alt="" width="250" height="480" src="/images/geekswithblogs_net/LifeLongTechie/10637/r_Using%20SSIS%20to%20send%20a%20HTML%20E-Mail%20Message%20with%20built-in%20table%20of%20Counts%20-%20SSIS%20screenshot.JPG" /&gt;&lt;/p&gt;
&lt;p&gt;The first part of the control flow is just for the override scenario.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;In the Execute SQL Task, it calls a stored procedure, which already formats the result into XML by using "&lt;span style="color: rgb(0,0,255)"&gt;FOR XML PATH&lt;/span&gt;(&lt;span style="color: rgb(255,0,0)"&gt;'Row'&lt;/span&gt;), &lt;span style="color: rgb(0,0,255)"&gt;ROOT&lt;/span&gt;(&lt;span style="color: rgb(255,0,0)"&gt;N'FieldingCounts'&lt;/span&gt;)".  The result XML string looks like this:&lt;/p&gt;
&lt;p&gt;&lt;span style="color: rgb(51,153,102)"&gt;&amp;lt;FieldingCounts&amp;gt;&lt;br /&gt;
  &amp;lt;Row&amp;gt;&lt;br /&gt;
    &amp;lt;CellId&amp;gt;M COD&amp;lt;/CellId&amp;gt;&lt;br /&gt;
    &amp;lt;Mailed&amp;gt;64&amp;lt;/Mailed&amp;gt;&lt;br /&gt;
    &amp;lt;ReMailed&amp;gt;210&amp;lt;/ReMailed&amp;gt;&lt;br /&gt;
    &amp;lt;TotalMail&amp;gt;274&amp;lt;/TotalMail&amp;gt;&lt;br /&gt;
    &amp;lt;EMailed&amp;gt;233&amp;lt;/EMailed&amp;gt;&lt;br /&gt;
    &amp;lt;TotalSent&amp;gt;297&amp;lt;/TotalSent&amp;gt;&lt;br /&gt;
  &amp;lt;/Row&amp;gt;&lt;br /&gt;
  &amp;lt;Row&amp;gt;&lt;br /&gt;
    &amp;lt;CellId&amp;gt;M National&amp;lt;/CellId&amp;gt;&lt;br /&gt;
    &amp;lt;Mailed&amp;gt;11&amp;lt;/Mailed&amp;gt;&lt;br /&gt;
    &amp;lt;ReMailed&amp;gt;59&amp;lt;/ReMailed&amp;gt;&lt;br /&gt;
    &amp;lt;TotalMail&amp;gt;70&amp;lt;/TotalMail&amp;gt;&lt;br /&gt;
    &amp;lt;EMailed&amp;gt;90&amp;lt;/EMailed&amp;gt;&lt;br /&gt;
    &amp;lt;TotalSent&amp;gt;101&amp;lt;/TotalSent&amp;gt;&lt;br /&gt;
  &amp;lt;/Row&amp;gt;&lt;br /&gt;
  &amp;lt;Row&amp;gt;&lt;br /&gt;
    &amp;lt;CellId&amp;gt;U COD&amp;lt;/CellId&amp;gt;&lt;br /&gt;
    &amp;lt;Mailed&amp;gt;91&amp;lt;/Mailed&amp;gt;&lt;br /&gt;
    &amp;lt;ReMailed&amp;gt;238&amp;lt;/ReMailed&amp;gt;&lt;br /&gt;
    &amp;lt;TotalMail&amp;gt;329&amp;lt;/TotalMail&amp;gt;&lt;br /&gt;
    &amp;lt;EMailed&amp;gt;291&amp;lt;/EMailed&amp;gt;&lt;br /&gt;
    &amp;lt;TotalSent&amp;gt;382&amp;lt;/TotalSent&amp;gt;&lt;br /&gt;
  &amp;lt;/Row&amp;gt;&lt;br /&gt;
  &amp;lt;Row&amp;gt;&lt;br /&gt;
    &amp;lt;CellId&amp;gt;U National&amp;lt;/CellId&amp;gt;&lt;br /&gt;
    &amp;lt;Mailed&amp;gt;63&amp;lt;/Mailed&amp;gt;&lt;br /&gt;
    &amp;lt;ReMailed&amp;gt;286&amp;lt;/ReMailed&amp;gt;&lt;br /&gt;
    &amp;lt;TotalMail&amp;gt;349&amp;lt;/TotalMail&amp;gt;&lt;br /&gt;
    &amp;lt;EMailed&amp;gt;374&amp;lt;/EMailed&amp;gt;&lt;br /&gt;
    &amp;lt;TotalSent&amp;gt;437&amp;lt;/TotalSent&amp;gt;&lt;br /&gt;
  &amp;lt;/Row&amp;gt;&lt;br /&gt;
&amp;lt;/FieldingCounts&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt; This result is saved into an internal SSIS variable with the following settings on the General tab and the Result Set tab:&lt;/p&gt;
&lt;p&gt;&lt;img alt="" width="502" height="480" src="/images/geekswithblogs_net/LifeLongTechie/10637/r_Using%20SSIS%20to%20send%20a%20HTML%20E-Mail%20Message%20with%20built-in%20table%20of%20Counts%20-%20ExecSQLTask_General.JPG" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt="" width="513" height="480" src="/images/geekswithblogs_net/LifeLongTechie/10637/r_Using%20SSIS%20to%20send%20a%20HTML%20E-Mail%20Message%20with%20built-in%20table%20of%20Counts%20-%20ExecSQLTask_Result%20Set.JPG" /&gt;&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;Now comes the trickier part.  We need to use the XML Task to format the XML string result into an HTML table, and I used Direct input XSLT&lt;/p&gt;
&lt;p&gt;&lt;img alt="" width="502" height="480" src="/images/geekswithblogs_net/LifeLongTechie/10637/r_Using%20SSIS%20to%20send%20a%20HTML%20E-Mail%20Message%20with%20built-in%20table%20of%20Counts%20-%20XMLTask_GeneralJPG.JPG" /&gt;&lt;/p&gt;
&lt;p&gt;And here is the code of XSLT:&lt;/p&gt;
&lt;p&gt;&lt;span style="color: rgb(0,0,255)"&gt;&amp;lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&amp;gt;&lt;br /&gt;
&amp;lt;xsl:output method="html" indent="yes"/&amp;gt;&lt;br /&gt;
  &amp;lt;xsl:template match="/ROOT"&amp;gt;&lt;br /&gt;
        &amp;lt;table border="1" cellpadding="6"&amp;gt;&lt;br /&gt;
          &amp;lt;tr&amp;gt;&lt;br /&gt;
            &amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
            &amp;lt;td&amp;gt;Mailed&amp;lt;/td&amp;gt;&lt;br /&gt;
            &amp;lt;td&amp;gt;Re-mailed&amp;lt;/td&amp;gt;&lt;br /&gt;
            &amp;lt;td&amp;gt;Total Mail (Mailed, Re-mailed)&amp;lt;/td&amp;gt;&lt;br /&gt;
            &amp;lt;td&amp;gt;E-mailed&amp;lt;/td&amp;gt;&lt;br /&gt;
            &amp;lt;td&amp;gt;Total Sent (Mailed, E-mailed)&amp;lt;/td&amp;gt;&lt;br /&gt;
          &amp;lt;/tr&amp;gt;&lt;br /&gt;
          &amp;lt;xsl:for-each select="FieldingCounts/Row"&amp;gt;&lt;br /&gt;
            &amp;lt;tr&amp;gt;&lt;br /&gt;
              &amp;lt;xsl:for-each select="./*"&amp;gt;&lt;br /&gt;
                &amp;lt;td&amp;gt;&lt;br /&gt;
                  &amp;lt;xsl:value-of select="." /&amp;gt;&lt;br /&gt;
                &amp;lt;/td&amp;gt;&lt;br /&gt;
              &amp;lt;/xsl:for-each&amp;gt;&lt;br /&gt;
            &amp;lt;/tr&amp;gt;&lt;br /&gt;
          &amp;lt;/xsl:for-each&amp;gt;&lt;br /&gt;
        &amp;lt;/table&amp;gt;&lt;br /&gt;
  &amp;lt;/xsl:template&amp;gt;&lt;br /&gt;
&amp;lt;/xsl:stylesheet&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt; Then a script task is used to send out an HTML email (as we are all painfully aware that SSIS Send Mail Task only sends plain text)&lt;br /&gt;
&lt;!--[if gte mso 9]&gt;&lt;xml&gt;
&lt;w:WordDocument&gt;
&lt;w:View&gt;Normal&lt;/w:View&gt;
&lt;w:Zoom&gt;0&lt;/w:Zoom&gt;
&lt;w:TrackMoves /&gt;
&lt;w:TrackFormatting /&gt;
&lt;w:PunctuationKerning /&gt;
&lt;w:ValidateAgainstSchemas /&gt;
&lt;w:SaveIfXMLInvalid&gt;false&lt;/w:SaveIfXMLInvalid&gt;
&lt;w:IgnoreMixedContent&gt;false&lt;/w:IgnoreMixedContent&gt;
&lt;w:AlwaysShowPlaceholderText&gt;false&lt;/w:AlwaysShowPlaceholderText&gt;
&lt;w:DoNotPromoteQF /&gt;
&lt;w:LidThemeOther&gt;EN-US&lt;/w:LidThemeOther&gt;
&lt;w:LidThemeAsian&gt;X-NONE&lt;/w:LidThemeAsian&gt;
&lt;w:LidThemeComplexScript&gt;X-NONE&lt;/w:LidThemeComplexScript&gt;
&lt;w:Compatibility&gt;
&lt;w:BreakWrappedTables /&gt;
&lt;w:SnapToGridInCell /&gt;
&lt;w:WrapTextWithPunct /&gt;
&lt;w:UseAsianBreakRules /&gt;
&lt;w:DontGrowAutofit /&gt;
&lt;w:SplitPgBreakAndParaMark /&gt;
&lt;w:DontVertAlignCellWithSp /&gt;
&lt;w:DontBreakConstrainedForcedTables /&gt;
&lt;w:DontVertAlignInTxbx /&gt;
&lt;w:Word11KerningPairs /&gt;
&lt;w:CachedColBalance /&gt;
&lt;/w:Compatibility&gt;
&lt;w:BrowserLevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&gt;
&lt;m:mathPr&gt;
&lt;m:mathFont m:val="Cambria Math" /&gt;
&lt;m:brkBin m:val="before" /&gt;
&lt;m:brkBinSub m:val="&amp;#45;-" /&gt;
&lt;m:smallFrac m:val="off" /&gt;
&lt;m:dispDef /&gt;
&lt;m:lMargin m:val="0" /&gt;
&lt;m:rMargin m:val="0" /&gt;
&lt;m:defJc m:val="centerGroup" /&gt;
&lt;m:wrapIndent m:val="1440" /&gt;
&lt;m:intLim m:val="subSup" /&gt;
&lt;m:naryLim m:val="undOvr" /&gt;
&lt;/m:mathPr&gt;&lt;/w:WordDocument&gt;
&lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;
&lt;w:LatentStyles DefLockedState="false" DefUnhideWhenUsed="true"
DefSemiHidden="true" DefQFormat="false" DefPriority="99"
LatentStyleCount="267"&gt;
&lt;w:LsdException Locked="false" Priority="0" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Normal" /&gt;
&lt;w:LsdException Locked="false" Priority="9" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="heading 1" /&gt;
&lt;w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 2" /&gt;
&lt;w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 3" /&gt;
&lt;w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 4" /&gt;
&lt;w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 5" /&gt;
&lt;w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 6" /&gt;
&lt;w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 7" /&gt;
&lt;w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 8" /&gt;
&lt;w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 9" /&gt;
&lt;w:LsdException Locked="false" Priority="39" Name="toc 1" /&gt;
&lt;w:LsdException Locked="false" Priority="39" Name="toc 2" /&gt;
&lt;w:LsdException Locked="false" Priority="39" Name="toc 3" /&gt;
&lt;w:LsdException Locked="false" Priority="39" Name="toc 4" /&gt;
&lt;w:LsdException Locked="false" Priority="39" Name="toc 5" /&gt;
&lt;w:LsdException Locked="false" Priority="39" Name="toc 6" /&gt;
&lt;w:LsdException Locked="false" Priority="39" Name="toc 7" /&gt;
&lt;w:LsdException Locked="false" Priority="39" Name="toc 8" /&gt;
&lt;w:LsdException Locked="false" Priority="39" Name="toc 9" /&gt;
&lt;w:LsdException Locked="false" Priority="35" QFormat="true" Name="caption" /&gt;
&lt;w:LsdException Locked="false" Priority="10" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Title" /&gt;
&lt;w:LsdException Locked="false" Priority="1" Name="Default Paragraph Font" /&gt;
&lt;w:LsdException Locked="false" Priority="11" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Subtitle" /&gt;
&lt;w:LsdException Locked="false" Priority="22" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Strong" /&gt;
&lt;w:LsdException Locked="false" Priority="20" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Emphasis" /&gt;
&lt;w:LsdException Locked="false" Priority="59" SemiHidden="false"
UnhideWhenUsed="false" Name="Table Grid" /&gt;
&lt;w:LsdException Locked="false" UnhideWhenUsed="false" Name="Placeholder Text" /&gt;
&lt;w:LsdException Locked="false" Priority="1" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="No Spacing" /&gt;
&lt;w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading" /&gt;
&lt;w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List" /&gt;
&lt;w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid" /&gt;
&lt;w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1" /&gt;
&lt;w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2" /&gt;
&lt;w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1" /&gt;
&lt;w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2" /&gt;
&lt;w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1" /&gt;
&lt;w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2" /&gt;
&lt;w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3" /&gt;
&lt;w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List" /&gt;
&lt;w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading" /&gt;
&lt;w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List" /&gt;
&lt;w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid" /&gt;
&lt;w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 1" /&gt;
&lt;w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 1" /&gt;
&lt;w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 1" /&gt;
&lt;w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 1" /&gt;
&lt;w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 1" /&gt;
&lt;w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 1" /&gt;
&lt;w:LsdException Locked="false" UnhideWhenUsed="false" Name="Revision" /&gt;
&lt;w:LsdException Locked="false" Priority="34" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="List Paragraph" /&gt;
&lt;w:LsdException Locked="false" Priority="29" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Quote" /&gt;
&lt;w:LsdException Locked="false" Priority="30" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Intense Quote" /&gt;
&lt;w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 1" /&gt;
&lt;w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 1" /&gt;
&lt;w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 1" /&gt;
&lt;w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 1" /&gt;
&lt;w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 1" /&gt;
&lt;w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 1" /&gt;
&lt;w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 1" /&gt;
&lt;w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 1" /&gt;
&lt;w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 2" /&gt;
&lt;w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 2" /&gt;
&lt;w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 2" /&gt;
&lt;w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 2" /&gt;
&lt;w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 2" /&gt;
&lt;w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 2" /&gt;
&lt;w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 2" /&gt;
&lt;w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 2" /&gt;
&lt;w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 2" /&gt;
&lt;w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 2" /&gt;
&lt;w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 2" /&gt;
&lt;w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 2" /&gt;
&lt;w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 2" /&gt;
&lt;w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 2" /&gt;
&lt;w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 3" /&gt;
&lt;w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 3" /&gt;
&lt;w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 3" /&gt;
&lt;w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 3" /&gt;
&lt;w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 3" /&gt;
&lt;w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 3" /&gt;
&lt;w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 3" /&gt;
&lt;w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 3" /&gt;
&lt;w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 3" /&gt;
&lt;w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 3" /&gt;
&lt;w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 3" /&gt;
&lt;w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 3" /&gt;
&lt;w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 3" /&gt;
&lt;w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 3" /&gt;
&lt;w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 4" /&gt;
&lt;w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 4" /&gt;
&lt;w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 4" /&gt;
&lt;w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 4" /&gt;
&lt;w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 4" /&gt;
&lt;w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 4" /&gt;
&lt;w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 4" /&gt;
&lt;w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 4" /&gt;
&lt;w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 4" /&gt;
&lt;w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 4" /&gt;
&lt;w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 4" /&gt;
&lt;w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 4" /&gt;
&lt;w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 4" /&gt;
&lt;w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 4" /&gt;
&lt;w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 5" /&gt;
&lt;w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 5" /&gt;
&lt;w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 5" /&gt;
&lt;w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 5" /&gt;
&lt;w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 5" /&gt;
&lt;w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 5" /&gt;
&lt;w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 5" /&gt;
&lt;w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 5" /&gt;
&lt;w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 5" /&gt;
&lt;w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 5" /&gt;
&lt;w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 5" /&gt;
&lt;w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 5" /&gt;
&lt;w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 5" /&gt;
&lt;w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 5" /&gt;
&lt;w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 6" /&gt;
&lt;w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 6" /&gt;
&lt;w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 6" /&gt;
&lt;w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 6" /&gt;
&lt;w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 6" /&gt;
&lt;w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 6" /&gt;
&lt;w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 6" /&gt;
&lt;w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 6" /&gt;
&lt;w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 6" /&gt;
&lt;w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 6" /&gt;
&lt;w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 6" /&gt;
&lt;w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 6" /&gt;
&lt;w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 6" /&gt;
&lt;w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 6" /&gt;
&lt;w:LsdException Locked="false" Priority="19" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Subtle Emphasis" /&gt;
&lt;w:LsdException Locked="false" Priority="21" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Intense Emphasis" /&gt;
&lt;w:LsdException Locked="false" Priority="31" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Subtle Reference" /&gt;
&lt;w:LsdException Locked="false" Priority="32" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Intense Reference" /&gt;
&lt;w:LsdException Locked="false" Priority="33" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Book Title" /&gt;
&lt;w:LsdException Locked="false" Priority="37" Name="Bibliography" /&gt;
&lt;w:LsdException Locked="false" Priority="39" QFormat="true" Name="TOC Heading" /&gt;
&lt;/w:LatentStyles&gt;
&lt;/xml&gt;&lt;![endif]--&gt;&lt;/p&gt;
&lt;div style="line-height: normal; margin-bottom: 0pt"&gt;&lt;span style="font-size: 10pt"&gt;using&lt;/span&gt;&lt;span style="font-size: 10pt"&gt; System;&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; margin-bottom: 0pt"&gt;&lt;span style="font-size: 10pt"&gt;using&lt;/span&gt;&lt;span style="font-size: 10pt"&gt; System.Data;&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; margin-bottom: 0pt"&gt;&lt;span style="font-size: 10pt"&gt;using&lt;/span&gt;&lt;span style="font-size: 10pt"&gt; Microsoft.SqlServer.Dts.Runtime;&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; margin-bottom: 0pt"&gt;&lt;span style="font-size: 10pt"&gt;using&lt;/span&gt;&lt;span style="font-size: 10pt"&gt; System.Windows.Forms;&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; margin-bottom: 0pt"&gt;&lt;span style="font-size: 10pt"&gt;using&lt;/span&gt;&lt;span style="font-size: 10pt"&gt; System.Net.Mail;&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; margin-bottom: 0pt"&gt;&lt;span style="font-size: 10pt"&gt;using&lt;/span&gt;&lt;span style="font-size: 10pt"&gt; System.Net;&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; margin-bottom: 0pt"&gt; &lt;/div&gt;
&lt;div style="line-height: normal; margin-bottom: 0pt"&gt;&lt;span style="font-size: 10pt"&gt;namespace&lt;/span&gt;&lt;span style="font-size: 10pt"&gt; ST_b829a2615e714bcfb55db0ce97be3901.csproj&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; margin-bottom: 0pt"&gt;&lt;span style="font-size: 10pt"&gt;{&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; margin-bottom: 0pt"&gt;&lt;span style="font-size: 10pt"&gt;    [System.AddIn.&lt;span style="color: rgb(43,145,175)"&gt;AddIn&lt;/span&gt;(&lt;span style="color: rgb(163,21,21)"&gt;"ScriptMain"&lt;/span&gt;, Version = &lt;span style="color: rgb(163,21,21)"&gt;"1.0"&lt;/span&gt;, Publisher = &lt;span style="color: rgb(163,21,21)"&gt;""&lt;/span&gt;, Description = &lt;span style="color: rgb(163,21,21)"&gt;""&lt;/span&gt;)]&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; margin-bottom: 0pt"&gt;&lt;span style="font-size: 10pt"&gt;    &lt;span style="color: blue"&gt;public&lt;/span&gt; &lt;span style="color: blue"&gt;partial&lt;/span&gt; &lt;span style="color: blue"&gt;class&lt;/span&gt; &lt;span style="color: rgb(43,145,175)"&gt;ScriptMain&lt;/span&gt; : Microsoft.SqlServer.Dts.Tasks.ScriptTask.&lt;span style="color: rgb(43,145,175)"&gt;VSTARTScriptObjectModelBase&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; margin-bottom: 0pt"&gt;&lt;span style="font-size: 10pt"&gt;    {&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; margin-bottom: 0pt"&gt; &lt;/div&gt;
&lt;div style="line-height: normal; margin-bottom: 0pt"&gt;&lt;span style="font-size: 10pt"&gt;        #region&lt;/span&gt;&lt;span style="font-size: 10pt"&gt; VSTA generated code&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; margin-bottom: 0pt"&gt;&lt;span style="font-size: 10pt"&gt;        &lt;span style="color: blue"&gt;enum&lt;/span&gt; &lt;span style="color: rgb(43,145,175)"&gt;ScriptResults&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; margin-bottom: 0pt"&gt;&lt;span style="font-size: 10pt"&gt;        {&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; margin-bottom: 0pt"&gt;&lt;span style="font-size: 10pt"&gt;            Success = Microsoft.SqlServer.Dts.Runtime.&lt;span style="color: rgb(43,145,175)"&gt;DTSExecResult&lt;/span&gt;.Success,&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; margin-bottom: 0pt"&gt;&lt;span style="font-size: 10pt"&gt;            Failure = Microsoft.SqlServer.Dts.Runtime.&lt;span style="color: rgb(43,145,175)"&gt;DTSExecResult&lt;/span&gt;.Failure&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; margin-bottom: 0pt"&gt;&lt;span style="font-size: 10pt"&gt;        };&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; margin-bottom: 0pt"&gt;&lt;span style="font-size: 10pt"&gt;        #endregion&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; margin-bottom: 0pt"&gt; &lt;/div&gt;
&lt;div style="line-height: normal; margin-bottom: 0pt"&gt;&lt;span style="font-size: 10pt"&gt;        &lt;span style="color: blue"&gt;public&lt;/span&gt; &lt;span style="color: blue"&gt;void&lt;/span&gt; Main()&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; margin-bottom: 0pt"&gt;&lt;span style="font-size: 10pt"&gt;        {&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; margin-bottom: 0pt"&gt;&lt;span style="font-size: 10pt"&gt;            &lt;span style="color: rgb(43,145,175)"&gt;String&lt;/span&gt; EmailMsgBody = &lt;span style="color: rgb(43,145,175)"&gt;String&lt;/span&gt;.Format(&lt;span style="color: rgb(163,21,21)"&gt;"&amp;lt;HTML&amp;gt;&amp;lt;BODY&amp;gt;&amp;lt;P&amp;gt;{0}&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;{1}&amp;lt;/P&amp;gt;&amp;lt;/BODY&amp;gt;&amp;lt;/HTML&amp;gt;"&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; margin-bottom: 0pt"&gt;&lt;span style="font-size: 10pt"&gt;                                                , Dts.Variables[&lt;span style="color: rgb(163,21,21)"&gt;"Config_SMTP_MessageSourceText"&lt;/span&gt;].Value.ToString()&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; margin-bottom: 0pt"&gt;&lt;span style="font-size: 10pt"&gt;                                                , Dts.Variables[&lt;span style="color: rgb(163,21,21)"&gt;"InternalStr_CountResultAfterXSLT"&lt;/span&gt;].Value.ToString());&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; margin-bottom: 0pt"&gt;&lt;span style="font-size: 10pt"&gt;            &lt;span style="color: rgb(43,145,175)"&gt;MailMessage&lt;/span&gt; EmailCountMsg = &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43,145,175)"&gt;MailMessage&lt;/span&gt;(Dts.Variables[&lt;span style="color: rgb(163,21,21)"&gt;"Config_SMTP_From"&lt;/span&gt;].Value.ToString().Replace(&lt;span style="color: rgb(163,21,21)"&gt;";"&lt;/span&gt;, &lt;span style="color: rgb(163,21,21)"&gt;","&lt;/span&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; margin-bottom: 0pt"&gt;&lt;span style="font-size: 10pt"&gt;                                                        , Dts.Variables[&lt;span style="color: rgb(163,21,21)"&gt;"Config_SMTP_Success_To"&lt;/span&gt;].Value.ToString().Replace(&lt;span style="color: rgb(163,21,21)"&gt;";"&lt;/span&gt;, &lt;span style="color: rgb(163,21,21)"&gt;","&lt;/span&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; margin-bottom: 0pt"&gt;&lt;span style="font-size: 10pt"&gt;                                                        , Dts.Variables[&lt;span style="color: rgb(163,21,21)"&gt;"Config_SMTP_SubjectLinePrefix"&lt;/span&gt;].Value.ToString() + &lt;span style="color: rgb(163,21,21)"&gt;" "&lt;/span&gt; + Dts.Variables[&lt;span style="color: rgb(163,21,21)"&gt;"InternalStr_FieldingDate"&lt;/span&gt;].Value.ToString()&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; margin-bottom: 0pt"&gt;&lt;span style="font-size: 10pt"&gt;                                                        , EmailMsgBody);&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; margin-bottom: 0pt"&gt;&lt;span style="font-size: 10pt"&gt;            &lt;span style="color: green"&gt;//EmailCountMsg.From.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; margin-bottom: 0pt"&gt;&lt;span style="font-size: 10pt"&gt;            EmailCountMsg.CC.Add(Dts.Variables[&lt;span style="color: rgb(163,21,21)"&gt;"Config_SMTP_Success_CC"&lt;/span&gt;].Value.ToString().Replace(&lt;span style="color: rgb(163,21,21)"&gt;";"&lt;/span&gt;, &lt;span style="color: rgb(163,21,21)"&gt;","&lt;/span&gt;));&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; margin-bottom: 0pt"&gt;&lt;span style="font-size: 10pt"&gt;            EmailCountMsg.IsBodyHtml = &lt;span style="color: blue"&gt;true&lt;/span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; margin-bottom: 0pt"&gt; &lt;/div&gt;
&lt;div style="line-height: normal; margin-bottom: 0pt"&gt;&lt;span style="font-size: 10pt"&gt;            &lt;span style="color: rgb(43,145,175)"&gt;SmtpClient&lt;/span&gt; SMTPForCount = &lt;span style="color: blue"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43,145,175)"&gt;SmtpClient&lt;/span&gt;(Dts.Variables[&lt;span style="color: rgb(163,21,21)"&gt;"Config_SMTP_ServerAddress"&lt;/span&gt;].Value.ToString());&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; margin-bottom: 0pt"&gt;&lt;span style="font-size: 10pt"&gt;            SMTPForCount.Credentials = &lt;span style="color: rgb(43,145,175)"&gt;CredentialCache&lt;/span&gt;.DefaultNetworkCredentials;&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; margin-bottom: 0pt"&gt; &lt;/div&gt;
&lt;div style="line-height: normal; margin-bottom: 0pt"&gt;&lt;span style="font-size: 10pt"&gt;            SMTPForCount.Send(EmailCountMsg);&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; margin-bottom: 0pt"&gt; &lt;/div&gt;
&lt;div style="line-height: normal; margin-bottom: 0pt"&gt;&lt;span style="font-size: 10pt"&gt;            Dts.TaskResult = (&lt;span style="color: blue"&gt;int&lt;/span&gt;)&lt;span style="color: rgb(43,145,175)"&gt;ScriptResults&lt;/span&gt;.Success;&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; margin-bottom: 0pt"&gt;&lt;span style="font-size: 10pt"&gt;        }&lt;/span&gt;&lt;/div&gt;
&lt;div style="line-height: normal; margin-bottom: 0pt"&gt;&lt;span style="font-size: 10pt"&gt;    }&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="line-height: 115%; font-size: 10pt"&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;p&gt;Note on this code: notice the email list has Replace(";", ",").  This is only here because the list is configurable in the SQL Job Step at Set Values, which does not react well with colons as email separator, but system.Net.Mail only handles comma as email separator, hence the extra replace in the string.&lt;/p&gt;
&lt;p&gt;The result is a nicely formatted email message with count information:&lt;/p&gt;
&lt;p&gt;&lt;img alt="" width="640" height="372" src="/images/geekswithblogs_net/LifeLongTechie/10637/r_Using%20SSIS%20to%20send%20a%20HTML%20E-Mail%20Message%20with%20built-in%20table%20of%20Counts%20-%20Result%20Email.JPG" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt="" src="file:///C:/DOCUME~1/shyrkh/LOCALS~1/Temp/moz-screenshot.png" /&gt;&lt;/p&gt; &lt;img src="http://geekswithblogs.net/LifeLongTechie/aggbug/143770.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Kevin Shyr</dc:creator>
            <guid>http://geekswithblogs.net/LifeLongTechie/archive/2011/02/02/using-ssis-to-send-a-html-e-mail-message-with-built-in.aspx</guid>
            <pubDate>Wed, 02 Feb 2011 21:47:05 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/LifeLongTechie/comments/143770.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/LifeLongTechie/archive/2011/02/02/using-ssis-to-send-a-html-e-mail-message-with-built-in.aspx#feedback</comments>
            <slash:comments>2</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/LifeLongTechie/comments/commentRss/143770.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/LifeLongTechie/services/trackbacks/143770.aspx</trackback:ping>
        </item>
        <item>
            <title>Execute SQL Job synchronously for BizTalk via a Stored Procedure call</title>
            <link>http://geekswithblogs.net/LifeLongTechie/archive/2010/11/01/execute-sql-job-synchronously-for-biztalk-via-a-stored-procedure.aspx</link>
            <description>&lt;p&gt;The async one was very easy to do.  However, in the process automation task I was given, there was a need to execute SQL Job and waiting for the execution result.  I couldn't find anything on the web to do what I wanted, so I make the following stored procedure.&lt;/p&gt;
&lt;p&gt;In addition, this stored procedure is quasi-synchronous.  I start the job and then check the status.  You can change the timing of the status check, but for the example below, it is "synchronous within 30 seconds."  I wish there is a better way to do this, but at my current knowledge base I only came up with this:&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;CREATE PROCEDURE [SQLJobExecSyncByName]&lt;br /&gt;
    @SQLJobName AS [varchar](128),&lt;br /&gt;
    @SQLJobStepName AS [varchar](128),&lt;br /&gt;
    @MinutesToWait AS [int],&lt;br /&gt;
    @JobExecStatus AS [bit] output&lt;br /&gt;
AS&lt;br /&gt;
BEGIN&lt;br /&gt;
    -- SET NOCOUNT ON added to prevent extra result sets from&lt;br /&gt;
    -- interfering with SELECT statements.&lt;br /&gt;
    SET NOCOUNT ON;&lt;br /&gt;
    &lt;br /&gt;
    DECLARE @JobStartDateTime AS DATETIME&lt;br /&gt;
    DECLARE @SPQuitDateTime AS DATETIME&lt;br /&gt;
    DECLARE @JobStartDateAsString AS VARCHAR(8)&lt;br /&gt;
    DECLARE @JobStartTimeAsString AS VARCHAR(6)&lt;br /&gt;
    DECLARE @SPOutcome AS BIT&lt;br /&gt;
    SET @JobStartDateTime = DATEADD(mi, -1, GETDATE())&lt;br /&gt;
    SET @SPQuitDateTime = DATEADD(mi, @MinutesToWait, GETDATE())&lt;br /&gt;
    SET @SPOutcome = 0&lt;br /&gt;
    SELECT @JobStartDateAsString = CONVERT(VARCHAR(8), @JobStartDateTime, 112)&lt;br /&gt;
    SELECT @JobStartTimeAsString = REPLACE(CONVERT(VARCHAR(8), @JobStartDateTime, 108), ':', '')&lt;br /&gt;
&lt;br /&gt;
    -- Create a temp table to store result&lt;br /&gt;
    CREATE TABLE #Result_sp_help_jobhistory&lt;br /&gt;
    (&lt;br /&gt;
        instance_id [int]&lt;br /&gt;
        , job_id [uniqueidentifier]&lt;br /&gt;
        , job_name [sysname]&lt;br /&gt;
        , step_id [int]&lt;br /&gt;
        , step_name [sysname]&lt;br /&gt;
        , sql_message_id [int]&lt;br /&gt;
        , sql_severity [int]&lt;br /&gt;
        , [message] [nvarchar](1024)&lt;br /&gt;
        , run_status [int]&lt;br /&gt;
        , run_date [int]&lt;br /&gt;
        , run_time [int]&lt;br /&gt;
        , run_duration [int]&lt;br /&gt;
        , operator_emailed [nvarchar](20)&lt;br /&gt;
        , operator_netsent [nvarchar](20)&lt;br /&gt;
        , operator_paged [nvarchar](20)&lt;br /&gt;
        , retries_attempted [int]&lt;br /&gt;
        , [server] [nvarchar](30)&lt;br /&gt;
    )&lt;br /&gt;
&lt;br /&gt;
    -- Start the job @SQLJobName at step @SQLJobStepName&lt;br /&gt;
    EXEC msdb.dbo.sp_start_job &lt;br /&gt;
        @job_name = @SQLJobName, &lt;br /&gt;
        @server_name = @@SERVERNAME,&lt;br /&gt;
        @step_name = @SQLJobStepName;&lt;br /&gt;
    &lt;br /&gt;
    WHILE (GETDATE() &amp;lt; @SPQuitDateTime) -- not time to quit yet&lt;br /&gt;
    BEGIN&lt;br /&gt;
        -- Check to see if the job has finished successfully&lt;br /&gt;
        INSERT INTO #Result_sp_help_jobhistory&lt;br /&gt;
            (instance_id&lt;br /&gt;
                , job_id&lt;br /&gt;
                , job_name&lt;br /&gt;
                , step_id&lt;br /&gt;
                , step_name&lt;br /&gt;
                , sql_message_id&lt;br /&gt;
                , sql_severity&lt;br /&gt;
                , [message]&lt;br /&gt;
                , run_status&lt;br /&gt;
                , run_date&lt;br /&gt;
                , run_time&lt;br /&gt;
                , run_duration&lt;br /&gt;
                , operator_emailed&lt;br /&gt;
                , operator_netsent&lt;br /&gt;
                , operator_paged&lt;br /&gt;
                , retries_attempted&lt;br /&gt;
                , [server]&lt;br /&gt;
            )&lt;br /&gt;
        EXEC msdb.dbo.sp_help_jobhistory&lt;br /&gt;
            @job_name = @SQLJobName, &lt;br /&gt;
            @start_run_date = @JobStartDateAsString, &lt;br /&gt;
            @start_run_time = @JobStartTimeAsString,&lt;br /&gt;
            --@run_status = 1, -- Success&lt;br /&gt;
            @mode = 'FULL'&lt;br /&gt;
&lt;br /&gt;
        IF(EXISTS(SELECT * &lt;br /&gt;
                    FROM #Result_sp_help_jobhistory&lt;br /&gt;
                    WHERE job_name = @SQLJobName&lt;br /&gt;
                        AND step_name = '(Job outcome)'&lt;br /&gt;
                        AND run_status = 1&lt;br /&gt;
                        AND @JobStartDateTime &amp;lt; CONVERT(DATETIME, CONVERT(VARCHAR(8), run_date) + ' ' + SUBSTRING(CONVERT(VARCHAR(6), run_time), 1, 2) + ':' + SUBSTRING(CONVERT(VARCHAR(6), run_time), 3, 2) + ':' + SUBSTRING(CONVERT(VARCHAR(6), run_time), 5, 2), 112)&lt;br /&gt;
                )&lt;br /&gt;
            )&lt;br /&gt;
        BEGIN&lt;br /&gt;
            -- The job has succceeded at least once after it was called&lt;br /&gt;
            SET @SPOutcome = 1&lt;br /&gt;
            GOTO FinishingStoredProcedureCall;&lt;br /&gt;
        END&lt;br /&gt;
        &lt;br /&gt;
        IF(EXISTS(SELECT * &lt;br /&gt;
                    FROM #Result_sp_help_jobhistory&lt;br /&gt;
                    WHERE job_name = @SQLJobName&lt;br /&gt;
                        AND step_name = '(Job outcome)'&lt;br /&gt;
                        AND run_status = 0&lt;br /&gt;
                        AND @JobStartDateTime &amp;lt; CONVERT(DATETIME, CONVERT(VARCHAR(8), run_date) + ' ' + SUBSTRING(CONVERT(VARCHAR(6), run_time), 1, 2) + ':' + SUBSTRING(CONVERT(VARCHAR(6), run_time), 3, 2) + ':' + SUBSTRING(CONVERT(VARCHAR(6), run_time), 5, 2), 112)&lt;br /&gt;
                )&lt;br /&gt;
            )&lt;br /&gt;
        BEGIN&lt;br /&gt;
            -- The job has failed after it was called&lt;br /&gt;
            GOTO FinishingStoredProcedureCall;&lt;br /&gt;
        END&lt;br /&gt;
        &lt;br /&gt;
        -- Clean up for the next run&lt;br /&gt;
        TRUNCATE TABLE #Result_sp_help_jobhistory&lt;br /&gt;
        &lt;br /&gt;
        -- check every 30 seconds&lt;br /&gt;
        WAITFOR DELAY '00:00:30';&lt;br /&gt;
    END&lt;br /&gt;
    &lt;br /&gt;
    FinishingStoredProcedureCall:&lt;br /&gt;
        SET @JobExecStatus = @SPOutcome&lt;br /&gt;
        DROP TABLE #Result_sp_help_jobhistory;&lt;br /&gt;
    &lt;br /&gt;
END&lt;br /&gt;
&lt;br /&gt;
 &lt;/p&gt;
&lt;p&gt;This SP was made to return an output parameter as result as to maximize reusability of the logic.  In order to use this from BizTalk, it was hooked into the following SP:&lt;/p&gt;
&lt;p&gt;CREATE PROCEDURE [SQLJobExecSyncByNameForBizTalk]&lt;br /&gt;
    @SQLJobName AS [varchar](128),&lt;br /&gt;
    @SQLJobStepName AS [varchar](128),&lt;br /&gt;
    @MinutesToWait AS [int]&lt;br /&gt;
AS&lt;br /&gt;
BEGIN&lt;br /&gt;
    -- SET NOCOUNT ON added to prevent extra result sets from&lt;br /&gt;
    -- interfering with SELECT statements.&lt;br /&gt;
    SET NOCOUNT ON;&lt;br /&gt;
    &lt;br /&gt;
    DECLARE @JobExecStatus AS BIT&lt;br /&gt;
&lt;br /&gt;
    EXEC [ODS].[SQLJobExecSyncByName] &lt;br /&gt;
        @SQLJobName = @SQLJobName,&lt;br /&gt;
        @SQLJobStepName = @SQLJobStepName,&lt;br /&gt;
        @MinutesToWait = @MinutesToWait,&lt;br /&gt;
        @JobExecStatus = @JobExecStatus OUTPUT;&lt;br /&gt;
        &lt;br /&gt;
    SELECT CONVERT(VARCHAR(8), @JobExecStatus)&lt;br /&gt;
         FOR XML PATH(N''), ROOT(N'JobExecStatus');&lt;br /&gt;
        &lt;br /&gt;
END&lt;/p&gt; &lt;img src="http://geekswithblogs.net/LifeLongTechie/aggbug/142555.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Kevin Shyr</dc:creator>
            <guid>http://geekswithblogs.net/LifeLongTechie/archive/2010/11/01/execute-sql-job-synchronously-for-biztalk-via-a-stored-procedure.aspx</guid>
            <pubDate>Mon, 01 Nov 2010 20:18:30 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/LifeLongTechie/comments/142555.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/LifeLongTechie/archive/2010/11/01/execute-sql-job-synchronously-for-biztalk-via-a-stored-procedure.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/LifeLongTechie/comments/commentRss/142555.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/LifeLongTechie/services/trackbacks/142555.aspx</trackback:ping>
        </item>
        <item>
            <title>Using SSIS as data source for SSRS</title>
            <link>http://geekswithblogs.net/LifeLongTechie/archive/2010/05/13/using-ssis-as-data-source-for-ssrs.aspx</link>
            <description>&lt;p&gt;Gotta try this:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.mssqltips.com/tip.asp?tip=1997&amp;amp;home"&gt;http://www.mssqltips.com/tip.asp?tip=1997&amp;amp;home&lt;/a&gt;&lt;/p&gt; &lt;img src="http://geekswithblogs.net/LifeLongTechie/aggbug/139797.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Kevin Shyr</dc:creator>
            <guid>http://geekswithblogs.net/LifeLongTechie/archive/2010/05/13/using-ssis-as-data-source-for-ssrs.aspx</guid>
            <pubDate>Thu, 13 May 2010 15:40:14 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/LifeLongTechie/comments/139797.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/LifeLongTechie/archive/2010/05/13/using-ssis-as-data-source-for-ssrs.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/LifeLongTechie/comments/commentRss/139797.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/LifeLongTechie/services/trackbacks/139797.aspx</trackback:ping>
        </item>
        <item>
            <title>Comparing ways to get rowcount from a database table.</title>
            <link>http://geekswithblogs.net/LifeLongTechie/archive/2010/02/25/comparing-ways-to-get-rowcount-from-a-database-table.aspx</link>
            <description>&lt;p&gt;&lt;span style="font-family: Tahoma"&gt;Just read this and found it very interesting.  The following are 2 queries to get rowcount on a database table:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Tahoma"&gt;Query 1 (the one everyone knows):&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt 40px; mso-layout-grid-align: none"&gt;&lt;span style="font-family: 'Courier New'; color: blue; font-size: 10pt; mso-no-proof: yes"&gt;SELECT&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 10pt; mso-no-proof: yes"&gt; &lt;span style="color: fuchsia"&gt;COUNT&lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;RowID&lt;span style="color: gray"&gt;)&lt;/span&gt; &lt;span style="color: blue"&gt;AS&lt;/span&gt; [RowCount]&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt 40px"&gt;&lt;span style="font-family: 'Courier New'; color: blue; font-size: 10pt; mso-no-proof: yes"&gt;FROM&lt;/span&gt;&lt;span style="font-family: 'Courier New'; font-size: 10pt; mso-no-proof: yes"&gt; elig_Inbox&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes"&gt;&lt;font face="Arial"&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none"&gt; &lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="font-family: Tahoma"&gt;&lt;span style="color: #000000"&gt;&lt;span style="font-size: 10pt; mso-no-proof: yes"&gt;Query 2 (the interesting one):&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none"&gt; &lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt 40px; mso-layout-grid-align: none"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; color: blue; font-size: 10pt; mso-no-proof: yes"&gt;SELECT&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes"&gt; st&lt;span style="color: gray"&gt;.&lt;/span&gt;row_count &lt;span style="color: blue"&gt;AS&lt;/span&gt; [RowCount]&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt 40px; mso-layout-grid-align: none"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; color: blue; font-size: 10pt; mso-no-proof: yes"&gt;FROM&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes"&gt; &lt;span style="color: green"&gt;sys.dm_db_partition_stats&lt;/span&gt; st&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt 40px; mso-layout-grid-align: none"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; color: blue; font-size: 10pt; mso-no-proof: yes"&gt;WHERE&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes"&gt; index_id &lt;span style="color: gray"&gt;&amp;lt;&lt;/span&gt; 2&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt 40px; mso-layout-grid-align: none"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; color: gray; font-size: 10pt; mso-no-proof: yes"&gt;and&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes"&gt; &lt;span style="color: fuchsia"&gt;OBJECT_NAME&lt;/span&gt;&lt;span style="color: gray"&gt;(&lt;/span&gt;&lt;span style="color: fuchsia"&gt;OBJECT_ID&lt;/span&gt;&lt;span style="color: gray"&gt;)=&lt;/span&gt;&lt;span style="color: red"&gt;'elig_Inbox'&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; color: red; font-size: 10pt; mso-no-proof: yes"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes"&gt;What's really interesting to me is that once you look at the execution plan of the 2 queries, you'd find the improvement in performance.&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt"&gt; &lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes"&gt;&lt;img width="1063" height="940" alt="" src="/images/geekswithblogs_net/LifeLongTechie/10637/o_RowCount%20Query%20Execution%20Plan.JPG" /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt"&gt; &lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt"&gt; &lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes"&gt;In real life, we probably don't care about it as often as we should.  For example, both queries, executed against a table of 260k + rows, returned result within a second.&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt"&gt; &lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; mso-no-proof: yes"&gt;However, one drawback I can think of immediately, is that Query 2 does not have the Table Hints option.  Most of the time we do RowCount because we need some logic done and we need to lock the table while we do the count.  I guess the way around that would be to manually initiate a lock before Query 2, then release it after.  It will be interesting to see whether that puts the 2 query performance back on par.&lt;/span&gt;&lt;/p&gt;
&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;img src="http://geekswithblogs.net/LifeLongTechie/aggbug/138172.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Kevin Shyr</dc:creator>
            <guid>http://geekswithblogs.net/LifeLongTechie/archive/2010/02/25/comparing-ways-to-get-rowcount-from-a-database-table.aspx</guid>
            <pubDate>Thu, 25 Feb 2010 16:07:06 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/LifeLongTechie/comments/138172.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/LifeLongTechie/archive/2010/02/25/comparing-ways-to-get-rowcount-from-a-database-table.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/LifeLongTechie/comments/commentRss/138172.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/LifeLongTechie/services/trackbacks/138172.aspx</trackback:ping>
        </item>
        <item>
            <title>Stop a SQL job in the first 5 days of the month, but report success</title>
            <link>http://geekswithblogs.net/LifeLongTechie/archive/2010/02/02/stop-a-sql-job-in-the-first-5-days-of.aspx</link>
            <description>&lt;p&gt;It is actually quite simple when I think this through:&lt;/p&gt;
&lt;ol&gt;
    &lt;li&gt;Make the first job step with this T-SQL query:&lt;br /&gt;
    &lt;span style="color: #0000ff"&gt;IF &lt;/span&gt;((&lt;span style="color: #0000ff"&gt;SELECT &lt;/span&gt;&lt;span style="color: #ff99cc"&gt;DAY&lt;/span&gt;(&lt;span style="color: #ff99cc"&gt;GETDATE&lt;/span&gt;())) &amp;lt; 6) &lt;span style="color: #0000ff"&gt;BEGIN&lt;/span&gt;&lt;br /&gt;
      &lt;span style="color: #0000ff"&gt;SELECT &lt;/span&gt;1/0&lt;br /&gt;
    &lt;span style="color: #0000ff"&gt;END&lt;/span&gt;&lt;br /&gt;
     &lt;/li&gt;
    &lt;li&gt;Go to the Advanced Tab of the Job Step property page.  Select "Quit the job reporting sucess" on the "On Failure Action" drop down.&lt;br /&gt;
    &lt;img width="693" height="200" alt="" src="/images/geekswithblogs_net/LifeLongTechie/10637/o_failure%20action.JPG" /&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;Note:  You can use RAISERROR, but the Severity has to be set to greater than 10.  To avoid future maintenance confusion, I decided to go with the basic fatal error generation.&lt;/p&gt; &lt;img src="http://geekswithblogs.net/LifeLongTechie/aggbug/137756.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Kevin Shyr</dc:creator>
            <guid>http://geekswithblogs.net/LifeLongTechie/archive/2010/02/02/stop-a-sql-job-in-the-first-5-days-of.aspx</guid>
            <pubDate>Tue, 02 Feb 2010 19:12:58 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/LifeLongTechie/comments/137756.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/LifeLongTechie/archive/2010/02/02/stop-a-sql-job-in-the-first-5-days-of.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/LifeLongTechie/comments/commentRss/137756.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/LifeLongTechie/services/trackbacks/137756.aspx</trackback:ping>
        </item>
    </channel>
</rss>
