<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://vsteamsystemcentral.com/cs21/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>VSTSC's Community Server</title><link>http://vsteamsystemcentral.com/cs21/blogs/default.aspx</link><description>&lt;P&gt;Community Server: The platform that enables you to build rich, interactive communities. &lt;BR&gt;VSTeamSystemCentral: Your Team System community!&lt;/P&gt;</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP2 (Build: 61129.2)</generator><item><title>Wait! SQL Agent Job</title><link>http://vsteamsystemcentral.com/cs21/blogs/steve_fibich/archive/2010/03/14/wait-sql-agent-job.aspx</link><pubDate>Sun, 14 Mar 2010 18:43:00 GMT</pubDate><guid isPermaLink="false">d291d4df-cf3d-4686-b1b1-8a0a96a3a0a7:515</guid><dc:creator>steve</dc:creator><slash:comments>0</slash:comments><description>&lt;P style="MARGIN:0in 0in 10pt;" class=MsoNormal&gt;&lt;SPAN style="mso-bidi-font-family:Calibri;mso-bidi-theme-font:minor-latin;"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;This is the second in at least a two part series dealing with SQL Agent Jobs.&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;In this post, we are creating a new procedure to be used instead of the system procedure sp_start_job when you need to wait for a SQL Agent Job prior to moving on to the next step in a program.&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;You may need to do this if you have a procedure that calls a SQL Agent job, or a SQL Agent Job that calls a second SQL Agent Job or a separate job scheduler that is reaching over to a SQL Server to call a job, and I’m guessing there are other reasons, but these are the reasons I’ve come across.&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT:0.5in;MARGIN:0in 0in 10pt;" class=MsoNormal&gt;&lt;SPAN style="mso-bidi-font-family:Calibri;mso-bidi-theme-font:minor-latin;"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;To accomplish this waiting on a SQL Agent Job we utilize the procedure introduced in part I of this series get_job_status_sp.&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;We use the built in sp_start_job procedure to call the SQL Agent Job as you normally would but we then use the get_job_status_sp to let us &lt;I style="mso-bidi-font-style:normal;"&gt;waitfor &lt;/I&gt;a job before returning control back to the calling processes.&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;There are a few other system stored procedures that are not documented in Books Online, so once again if this kind of thing makes you squeamish I understand.&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;There is some risk of using system procedures that are not documented because they could change any time without notice.&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;Unfortunately if you need this functionally you don’t have a lot of choice.&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;Outside of those items, this is basically just a while loop using the get_job_status_sp along with the waitfor command.&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;It’s pretty simple and pretty straight forward so if you feel the need to modify it in the future it should be easy to do so.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT:0.5in;MARGIN:0in 0in 10pt;" class=MsoNormal&gt;&lt;I style="mso-bidi-font-style:normal;"&gt;&lt;SPAN style="mso-bidi-font-family:Calibri;mso-bidi-theme-font:minor-latin;"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&lt;/SPAN&gt;One note of change to that procedure get_job_status_sp, &lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&lt;/SPAN&gt;I have moved it into a new schema “jobs” inside the util database instead of leaving it in the dbo schema.&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;All of the new code is provided as well as the original on this website.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;" class=MsoNormal&gt;&lt;SPAN style="mso-bidi-font-family:Calibri;mso-bidi-theme-font:minor-latin;"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Here it is below:&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;" class=MsoNormal&gt;&lt;SPAN style="mso-bidi-font-family:Calibri;mso-bidi-theme-font:minor-latin;"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;(Also available without commentary here: &lt;A href="http://vsteamsystemcentral.com/cs21/files/folders/steve/entry520.aspx"&gt;0004_utilis.jobs.get_job_status_sp.sql&lt;/A&gt; )&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;" class=MsoNormal&gt;&lt;SPAN style="mso-bidi-font-family:Calibri;mso-bidi-theme-font:minor-latin;"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;(You may also want the util db build script here: &lt;A href="http://vsteamsystemcentral.com/cs21/files/folders/steve/entry513.aspx"&gt;0001_create_database_util.sql&lt;/A&gt; &lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&lt;/SPAN&gt;and the &lt;A href="http://vsteamsystemcentral.com/cs21/files/folders/steve/entry516.aspx"&gt;0002_create_schemas_for_database_util.sql&lt;/A&gt; schema script)&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="mso-bidi-font-family:Calibri;mso-bidi-theme-font:minor-latin;"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;(Finally the entire jobs schema will be kept up to date with each post at &lt;A href="http://vsteamsystemcentral.com/cs21/files/folders/steve/entry521.aspx"&gt;CompleteJobsSchema.zip&lt;/A&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;use&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt; util&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:green;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;--======================--&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:green;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;--Logging some basic info&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:green;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;--======================--&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;print&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt; &lt;SPAN style="COLOR:fuchsia;"&gt;@@SERVERNAME&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;print&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt; &lt;SPAN style="COLOR:fuchsia;"&gt;SUSER_NAME&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;()&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;print&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt; &lt;SPAN style="COLOR:fuchsia;"&gt;GETDATE&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;()&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;go&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;:So the code above is just some standard logging information that I like to record when my scripts run incase I’m am writing the output to a log somewhere.&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;This was something I saw Andy Leonard do in one of his presentations and I think it’s a good idea, so I’ve started to incorporate it in all my scripts.&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;This will also be a good thing to have if you have an automated deployment environment or want to have one in the future. (Standard code disclaimer/blurb…sorry but I think it’s worth repeating)&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:green;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;-- ==Depending on your build enviomrent you may want to comment out the destructive drop below== --&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;IF&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;EXISTS&lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;SELECT&lt;/SPAN&gt; &lt;SPAN style="COLOR:gray;"&gt;*&lt;/SPAN&gt; &lt;SPAN style="COLOR:blue;"&gt;FROM&lt;/SPAN&gt; &lt;SPAN style="COLOR:green;"&gt;sys&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;.&lt;/SPAN&gt;&lt;SPAN style="COLOR:green;"&gt;objects&lt;/SPAN&gt; &lt;SPAN style="COLOR:blue;"&gt;WHERE&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:fuchsia;"&gt;OBJECT_ID&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR:red;"&gt;N'[jobs].[start_job]'&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;)&lt;/SPAN&gt; &lt;SPAN style="COLOR:gray;"&gt;AND&lt;/SPAN&gt; &lt;SPAN style="COLOR:blue;"&gt;type&lt;/SPAN&gt; &lt;SPAN style="COLOR:gray;"&gt;in&lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR:red;"&gt;N'P'&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;,&lt;/SPAN&gt; &lt;SPAN style="COLOR:red;"&gt;N'PC'&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;))&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;DROP&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt; &lt;SPAN style="COLOR:blue;"&gt;PROCEDURE&lt;/SPAN&gt; [jobs]&lt;SPAN style="COLOR:gray;"&gt;.&lt;/SPAN&gt;[start_job]&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;: Nothing special above except for if you do not want to script out your permissions every time you run this script you may want to comment it out so you don’t accidently remove permissions on this proc.&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;When I run this script my account is either in the sysAdmin role or I script out the permissions in a separate file. (Standard code disclaimer/blurb…sorry but I think it’s worth repeating)&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;GO&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;create&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt; &lt;SPAN style="COLOR:blue;"&gt;proc&lt;/SPAN&gt; jobs&lt;SPAN style="COLOR:gray;"&gt;.&lt;/SPAN&gt;start_job &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt;@job_id &lt;SPAN style="COLOR:blue;"&gt;UNIQUEIDENTIFIER&lt;/SPAN&gt; &lt;SPAN style="COLOR:gray;"&gt;=&lt;/SPAN&gt; &lt;SPAN style="COLOR:gray;"&gt;NULL&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:gray;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt;@job_name &lt;SPAN style="COLOR:blue;"&gt;SYSNAME&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;=&lt;/SPAN&gt; &lt;SPAN style="COLOR:gray;"&gt;NULL&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:gray;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt;@check_seconds &lt;SPAN style="COLOR:blue;"&gt;int&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;=&lt;/SPAN&gt;59&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;as&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;: Notice that the procedure does not require either variable but it will need one; this is to be handled later in the script.&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;Some people like to have the comments below listed right before the create object statement so it is recorded in the system tables along with the object but not in it.&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;I like to have inside the object if I can. (Standard code disclaimer/blurb…sorry but I think it’s worth repeating)&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:green;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;-- =============================================== --&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:green;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;-- Author:Steve Fibich&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:green;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;-- Create date: 02/25/2010&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:green;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;-- Description: This procedure allows you to call&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:green;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;-- a SQL Agent Job and wait until it finishes. It&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:green;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;-- also waits for the called SQL Agent job to finish&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:green;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;-- if it is already running before it response to its&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:green;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;-- initial call.&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;This procedure has 3 variables; First&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:green;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;-- is the job_id the second is job name only one of these&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:green;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;-- can be populated and one of these must be populated.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:green;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;-- The third is a truly optional varaible that determines&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:green;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;-- the interval with which the procedure will sleep while&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:green;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;-- waiting for a called SQL Agent job to finish, this by &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:green;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;-- default is set to 59 seconds.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:green;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;--&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:green;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;-- Value&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;Description (From Books Online for SP_HELP_JOBS) &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:green;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;-- 0&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;Returns only those jobs that are not idle or suspended. &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:green;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;-- 1&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;Executing.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:green;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;-- 2&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;Waiting for thread.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:green;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;-- 3&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;Between retries.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:green;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;-- 4&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;Idle.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:green;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;-- 5&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;Suspended.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:green;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;-- 7&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;Performing completion actions.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:green;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;-- =============================================== --&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;BEGIN&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;SET&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt; &lt;SPAN style="COLOR:blue;"&gt;NOCOUNT&lt;/SPAN&gt; &lt;SPAN style="COLOR:blue;"&gt;ON&lt;/SPAN&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;:SET NOCOUNT ON, why bother returning information about rows affected, we aren’t affecting any rows and this information would provided any value.&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;if &lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:gray;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;((&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt;@job_id &lt;SPAN style="COLOR:gray;"&gt;is&lt;/SPAN&gt; &lt;SPAN style="COLOR:gray;"&gt;null&lt;/SPAN&gt; &lt;SPAN style="COLOR:gray;"&gt;and&lt;/SPAN&gt; @job_name &lt;SPAN style="COLOR:gray;"&gt;is&lt;/SPAN&gt; &lt;SPAN style="COLOR:gray;"&gt;null)&lt;/SPAN&gt; &lt;SPAN style="COLOR:gray;"&gt;or&lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;(&lt;/SPAN&gt;@job_id &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 style="COLOR:gray;"&gt;and&lt;/SPAN&gt; @job_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;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;BEGIN&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;SPAN style="mso-tab-count:1;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;RAISERROR&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR:red;"&gt;N'Either @job_id or @job_name is required.'&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;,&lt;/SPAN&gt;10&lt;SPAN style="COLOR:gray;"&gt;,&lt;/SPAN&gt;1&lt;SPAN style="COLOR:gray;"&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;END&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt; @check_seconds &lt;SPAN style="COLOR:gray;"&gt;&amp;gt;&lt;/SPAN&gt;59&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;SPAN style="mso-tab-count:1;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;BEGIN&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;SPAN style="mso-tab-count:2;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;RAISERROR&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR:red;"&gt;N'@check_seconds must be less than 60. @check_seconds=%d'&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;,&lt;/SPAN&gt;10&lt;SPAN style="COLOR:gray;"&gt;,&lt;/SPAN&gt;1&lt;SPAN style="COLOR:gray;"&gt;,&lt;/SPAN&gt;@check_seconds&lt;SPAN style="COLOR:gray;"&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;SPAN style="mso-tab-count:1;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;END&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;: Ok the max value that is allowed for the check seconds variable is 59, and the reason for this is twofold.&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;First I think checking a job any longer than 60 seconds apart leaves a window that is two large, if I allowed the window to be 30 minutes or 23 hours this would allow this project to run for that long after the job had finished if the job just finished after the job status check.&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;If you leave the value for check status at 59 seconds and the job runs for an hour you have only check that status 60 times, which doesn’t seem too long to me.&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;Second, and this was one of the important reasons was changing a Integer to a string formatted for the wait command was just easier if it was less than 60.&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;Maybe in a future enhancement I’ll change it to take minutes and hours but so far this has served me well.&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;IF &lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:gray;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;((&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt;@job_id &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 style="COLOR:gray;"&gt;OR&lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;(&lt;/SPAN&gt;@job_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 style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;BEGIN&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;EXECUTE&lt;/SPAN&gt; msdb&lt;SPAN style="COLOR:gray;"&gt;.&lt;/SPAN&gt;dbo&lt;SPAN style="COLOR:gray;"&gt;.&lt;/SPAN&gt;&lt;SPAN style="COLOR:maroon;"&gt;sp_verify_job_identifiers&lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:red;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;'@job_name'&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="COLOR:red;"&gt;'@job_id'&lt;/SPAN&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;,&lt;/SPAN&gt;@job_name &lt;SPAN style="COLOR:blue;"&gt;OUTPUT&lt;/SPAN&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;,&lt;/SPAN&gt;@job_id&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;OUTPUT&lt;/SPAN&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;END&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;SPAN style="mso-bidi-font-family:Calibri;mso-bidi-theme-font:minor-latin;mso-no-proof:yes;"&gt;:Calling sp_verify_job_identifiers gaurantees that we have a valid job id, it will over right our @job_id with a valid value if we only had a job_name and if we had a job_id it will overwrite it with the same value and populate the @job_name variable.&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:green;mso-no-proof:yes;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;declare&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt; @job_status &lt;SPAN style="COLOR:blue;"&gt;int&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;declare&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt; @len &lt;SPAN style="COLOR:blue;"&gt;tinyint&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;declare&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt; @delay &lt;SPAN style="COLOR:blue;"&gt;as&lt;/SPAN&gt; &lt;SPAN style="COLOR:blue;"&gt;char&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;(&lt;/SPAN&gt;8&lt;SPAN style="COLOR:gray;"&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;declare&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt; @check_seconds_vc &lt;SPAN style="COLOR:blue;"&gt;char&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;(&lt;/SPAN&gt;2&lt;SPAN style="COLOR:gray;"&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:gray;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;set&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt; @check_seconds_vc&lt;SPAN style="COLOR:gray;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR:fuchsia;"&gt;cast&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;(&lt;/SPAN&gt;@check_seconds &lt;SPAN style="COLOR:blue;"&gt;as&lt;/SPAN&gt; &lt;SPAN style="COLOR:blue;"&gt;char&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;(&lt;/SPAN&gt;2&lt;SPAN style="COLOR:gray;"&gt;))&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;set&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt; @len&lt;SPAN style="COLOR:gray;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR:fuchsia;"&gt;len&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;(&lt;/SPAN&gt;@check_seconds_vc&lt;SPAN style="COLOR:gray;"&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;set&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt; @delay &lt;SPAN style="COLOR:gray;"&gt;=&lt;/SPAN&gt; &lt;SPAN style="COLOR:red;"&gt;'00:00:00'&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;set&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt; @delay&lt;SPAN style="COLOR:gray;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR:fuchsia;"&gt;stuff&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;(&lt;/SPAN&gt;@delay&lt;SPAN style="COLOR:gray;"&gt;,&lt;/SPAN&gt;9&lt;SPAN style="COLOR:gray;"&gt;-&lt;/SPAN&gt;@len&lt;SPAN style="COLOR:gray;"&gt;,&lt;/SPAN&gt;@len&lt;SPAN style="COLOR:gray;"&gt;,&lt;/SPAN&gt;@check_seconds_vc&lt;SPAN style="COLOR:gray;"&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:gray;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="mso-bidi-font-family:Calibri;mso-bidi-theme-font:minor-latin;mso-no-proof:yes;"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;:Above is some logic to convert a integer value into a seconds value in the string format for the waitfor command.&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;Long story short I’m stuffing the @check_seconds variable converted into a charater string into a preformated string ’00:00:00’ based on the length of the check seconds string.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:gray;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:green;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;-- ==Intial Job check== --&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;execute&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt; jobs&lt;SPAN style="COLOR:gray;"&gt;.&lt;/SPAN&gt;get_job_status_sp&lt;SPAN style="COLOR:blue;"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt;@job_id&lt;SPAN style="COLOR:gray;"&gt;=&lt;/SPAN&gt;@job_id&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:gray;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt;@job_status&lt;SPAN style="COLOR:gray;"&gt;=&lt;/SPAN&gt;@job_status &lt;SPAN style="COLOR:blue;"&gt;output&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;WHILE&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt; @job_status &lt;SPAN style="COLOR:gray;"&gt;not&lt;/SPAN&gt; &lt;SPAN style="COLOR:gray;"&gt;in&lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;(&lt;/SPAN&gt;4&lt;SPAN style="COLOR:gray;"&gt;,&lt;/SPAN&gt;5&lt;SPAN style="COLOR:gray;"&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;BEGIN&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;SPAN style="mso-tab-count:1;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;waitfor&lt;/SPAN&gt; &lt;SPAN style="COLOR:blue;"&gt;delay&lt;/SPAN&gt; @delay&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;SPAN style="mso-tab-count:1;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;execute&lt;/SPAN&gt; jobs&lt;SPAN style="COLOR:gray;"&gt;.&lt;/SPAN&gt;get_job_status_sp&lt;SPAN style="COLOR:blue;"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;SPAN style="mso-tab-count:1;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt;@job_id&lt;SPAN style="COLOR:gray;"&gt;=&lt;/SPAN&gt;@job_id&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;SPAN style="mso-tab-count:1;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;,&lt;/SPAN&gt;@job_status&lt;SPAN style="COLOR:gray;"&gt;=&lt;/SPAN&gt;@job_status &lt;SPAN style="COLOR:blue;"&gt;output&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;END&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;SPAN style="mso-bidi-font-family:Calibri;mso-bidi-theme-font:minor-latin;mso-no-proof:yes;"&gt;: This initial status check allows for this job to wait for a SQL Server Agent job if it is already running.&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:green;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:green;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;-- ==Job is called; wait loop == --&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;FONT color=#000000&gt; @job_status &lt;/FONT&gt;&lt;SPAN style="COLOR:gray;"&gt;in&lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;(&lt;/SPAN&gt;&lt;FONT color=#000000&gt;4&lt;/FONT&gt;&lt;SPAN style="COLOR:gray;"&gt;,&lt;/SPAN&gt;&lt;FONT color=#000000&gt;5&lt;/FONT&gt;&lt;SPAN style="COLOR:gray;"&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;BEGIN&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:green;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;--&lt;SPAN style="mso-tab-count:1;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;print 'pre-execute'&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;SPAN style="mso-tab-count:1;"&gt;&lt;FONT color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;execute&lt;/SPAN&gt;&lt;FONT color=#000000&gt; msdb&lt;/FONT&gt;&lt;SPAN style="COLOR:gray;"&gt;.&lt;/SPAN&gt;&lt;FONT color=#000000&gt;dbo&lt;/FONT&gt;&lt;SPAN style="COLOR:gray;"&gt;.&lt;/SPAN&gt;&lt;SPAN style="COLOR:maroon;"&gt;sp_start_job&lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt; &lt;/SPAN&gt;&lt;FONT color=#000000&gt;@job_id&lt;/FONT&gt;&lt;SPAN style="COLOR:gray;"&gt;=&lt;/SPAN&gt;&lt;FONT color=#000000&gt;@job_id&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;SPAN style="mso-tab-count:1;"&gt;&lt;FONT color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;waitfor&lt;/SPAN&gt;&lt;FONT color=#000000&gt; &lt;/FONT&gt;&lt;SPAN style="COLOR:blue;"&gt;delay&lt;/SPAN&gt;&lt;FONT color=#000000&gt; &lt;/FONT&gt;&lt;SPAN style="COLOR:red;"&gt;'00:00:00'&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:green;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;--&lt;SPAN style="mso-tab-count:1;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;print 'post-execute'&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;SPAN style="mso-tab-count:1;"&gt;&lt;FONT color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;execute&lt;/SPAN&gt;&lt;FONT color=#000000&gt; jobs&lt;/FONT&gt;&lt;SPAN style="COLOR:gray;"&gt;.&lt;/SPAN&gt;&lt;FONT color=#000000&gt;get_job_status_sp&lt;/FONT&gt;&lt;SPAN style="COLOR:blue;"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;SPAN style="mso-tab-count:1;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;FONT color=#000000&gt;@job_id&lt;/FONT&gt;&lt;SPAN style="COLOR:gray;"&gt;=&lt;/SPAN&gt;&lt;FONT color=#000000&gt;@job_id&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;SPAN style="mso-tab-count:1;"&gt;&lt;FONT color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;,&lt;/SPAN&gt;&lt;FONT color=#000000&gt;@job_status&lt;/FONT&gt;&lt;SPAN style="COLOR:gray;"&gt;=&lt;/SPAN&gt;&lt;FONT color=#000000&gt;@job_status &lt;/FONT&gt;&lt;SPAN style="COLOR:blue;"&gt;output&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:green;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;--&lt;SPAN style="mso-tab-count:1;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;print 'status' + cast(@job_status as char(10))&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;SPAN style="mso-tab-count:1;"&gt;&lt;FONT color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;WHILE&lt;/SPAN&gt;&lt;FONT color=#000000&gt; @job_status &lt;/FONT&gt;&lt;SPAN style="COLOR:gray;"&gt;not&lt;/SPAN&gt;&lt;FONT color=#000000&gt; &lt;/FONT&gt;&lt;SPAN style="COLOR:gray;"&gt;in&lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;(&lt;/SPAN&gt;&lt;FONT color=#000000&gt;4&lt;/FONT&gt;&lt;SPAN style="COLOR:gray;"&gt;,&lt;/SPAN&gt;&lt;FONT color=#000000&gt;5&lt;/FONT&gt;&lt;SPAN style="COLOR:gray;"&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;SPAN style="mso-tab-count:1;"&gt;&lt;FONT color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;BEGIN&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;SPAN style="mso-tab-count:2;"&gt;&lt;FONT color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;waitfor&lt;/SPAN&gt;&lt;FONT color=#000000&gt; &lt;/FONT&gt;&lt;SPAN style="COLOR:blue;"&gt;delay&lt;/SPAN&gt;&lt;FONT color=#000000&gt; @delay&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;SPAN style="mso-tab-count:2;"&gt;&lt;FONT color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;execute&lt;/SPAN&gt;&lt;FONT color=#000000&gt; jobs&lt;/FONT&gt;&lt;SPAN style="COLOR:gray;"&gt;.&lt;/SPAN&gt;&lt;FONT color=#000000&gt;get_job_status_sp&lt;/FONT&gt;&lt;SPAN style="COLOR:blue;"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;SPAN style="mso-tab-count:2;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;FONT color=#000000&gt;@job_id&lt;/FONT&gt;&lt;SPAN style="COLOR:gray;"&gt;=&lt;/SPAN&gt;&lt;FONT color=#000000&gt;@job_id&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;SPAN style="mso-tab-count:2;"&gt;&lt;FONT color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;,&lt;/SPAN&gt;&lt;FONT color=#000000&gt;@job_status&lt;/FONT&gt;&lt;SPAN style="COLOR:gray;"&gt;=&lt;/SPAN&gt;&lt;FONT color=#000000&gt;@job_status &lt;/FONT&gt;&lt;SPAN style="COLOR:blue;"&gt;output&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;SPAN style="mso-tab-count:1;"&gt;&lt;FONT color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;END&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;END&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN:0in 0in 10pt;" class=MsoNormal&gt;&lt;FONT color=#000000 size=3 face=Calibri&gt;: Finally the meat of the procedure.&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;After the initial check of the job status we know that SQL Agent job is not running.&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;At this point we execute the required job using the system procedure sp_start_job and then we check the status, who knows it could be a very fast running job, or it could have failed. &lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;Note the waitfor delay ’00:00:00’&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;while this has a wait of nothing I found if I checked the job status right away with nothing else I could actually get the status before the job was started, but then a fraction of a second later it was running.&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;This tells me that there is some delay between starting a job with sp_start_job and getting the correct information back from the xp_sqlAgent_enum_jobs extended stored procedure which then also introduces this delay into my get_job_status_sp.&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;Also note that get_job_status_sp is now in the jobs schema. Then we wait if the job is running, which is what we expect.&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;Then check the job status and continue this wait/check loop until the job is finished.&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;That’s it that simple.&lt;/FONT&gt;&lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;END&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt; &lt;SPAN style="COLOR:green;"&gt;--PROC&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN:0in 0in 10pt;" class=MsoNormal&gt;&lt;SPAN style="mso-bidi-font-family:Calibri;mso-bidi-theme-font:minor-latin;"&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN:0in 0in 10pt;" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;:TEST!:&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN:0in 0in 10pt;" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;: The code below tests the new procedure and insures it properly runs and waits for a SQL Agent job.&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;This test assumes you created the SlowlyRunningJob in part I of this series.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;use&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt; util&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:green;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;--======================--&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:green;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;--Logging some basic info&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:green;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;--======================--&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;print&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt; &lt;SPAN style="COLOR:fuchsia;"&gt;@@SERVERNAME&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;print&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt; &lt;SPAN style="COLOR:fuchsia;"&gt;SUSER_NAME&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;()&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;print&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt; &lt;SPAN style="COLOR:fuchsia;"&gt;GETDATE&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;()&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;go&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;execute&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt; msdb&lt;SPAN style="COLOR:gray;"&gt;.&lt;/SPAN&gt;dbo&lt;SPAN style="COLOR:gray;"&gt;.&lt;/SPAN&gt;&lt;SPAN style="COLOR:maroon;"&gt;sp_start_job&lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt; &lt;/SPAN&gt;@job_name&lt;SPAN style="COLOR:gray;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR:red;"&gt;'SlowlyRunningJob'&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;go&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;execute&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt; msdb&lt;SPAN style="COLOR:gray;"&gt;.&lt;/SPAN&gt;dbo&lt;SPAN style="COLOR:gray;"&gt;.&lt;/SPAN&gt;&lt;SPAN style="COLOR:maroon;"&gt;sp_start_job&lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt; &lt;/SPAN&gt;@job_name&lt;SPAN style="COLOR:gray;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR:red;"&gt;'SlowlyRunningJob'&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:green;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;-- ==Failure after this section runs because the job is already running== --&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;go&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;execute&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt; jobs&lt;SPAN style="COLOR:gray;"&gt;.&lt;/SPAN&gt;start_job&lt;SPAN style="COLOR:blue;"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt;@job_name&lt;SPAN style="COLOR:gray;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR:red;"&gt;'SlowlyRunningJob'&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:gray;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt;@check_seconds&lt;SPAN style="COLOR:gray;"&gt;=&lt;/SPAN&gt;2&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;go&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;execute&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt; msdb&lt;SPAN style="COLOR:gray;"&gt;.&lt;/SPAN&gt;dbo&lt;SPAN style="COLOR:gray;"&gt;.&lt;/SPAN&gt;&lt;SPAN style="COLOR:maroon;"&gt;sp_start_job&lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt; &lt;/SPAN&gt;@job_name&lt;SPAN style="COLOR:gray;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR:red;"&gt;'SlowlyRunningJob'&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:green;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;-- ==Success after this section runs== --&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN:0in 0in 10pt;" class=MsoNormal&gt;&lt;SPAN style="mso-bidi-font-family:Calibri;mso-bidi-theme-font:minor-latin;"&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN:0in 0in 10pt;" class=MsoNormal&gt;&lt;SPAN style="mso-bidi-font-family:Calibri;mso-bidi-theme-font:minor-latin;"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;If anyone knows how to accurately or more accurately get the status of a job without using xp_sql_agent_enum jobs please let me know.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://vsteamsystemcentral.com/cs21/aggbug.aspx?PostID=515" width="1" height="1"&gt;</description><category domain="http://vsteamsystemcentral.com/cs21/blogs/steve_fibich/archive/tags/T-SQL/default.aspx">T-SQL</category><category domain="http://vsteamsystemcentral.com/cs21/blogs/steve_fibich/archive/tags/util+db/default.aspx">util db</category></item><item><title>SQL Server Agent Job Status</title><link>http://vsteamsystemcentral.com/cs21/blogs/steve_fibich/archive/2010/03/09/sql-server-agent-job-satus.aspx</link><pubDate>Tue, 09 Mar 2010 17:45:00 GMT</pubDate><guid isPermaLink="false">d291d4df-cf3d-4686-b1b1-8a0a96a3a0a7:512</guid><dc:creator>steve</dc:creator><slash:comments>0</slash:comments><description>&lt;P style="MARGIN:0in 0in 0pt;"&gt;&lt;B style="mso-bidi-font-weight:normal;"&gt;&lt;SPAN style="FONT-FAMILY:'Arial','sans-serif';FONT-SIZE:10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/B&gt;&lt;/P&gt;&lt;SPAN style="LINE-HEIGHT:115%;FONT-FAMILY:'Calibri','sans-serif';FONT-SIZE:11pt;mso-ascii-theme-font:minor-latin;mso-hansi-theme-font:minor-latin;mso-bidi-theme-font:minor-latin;"&gt;I wanted to talk about SQL Server Agent Job's status, but before we get into that I want to talk about Utility databases.&amp;nbsp; I've noticed over the years some of the DBA's and database developers have utility databases and some have a folder of commonly used scripts.&amp;nbsp; It seems as if the&amp;nbsp;more efficient ones have a utility database they can deploy in an environment or to individual servers in an environment and quickly have a set of useful tools up and running in an environment.&amp;nbsp; Unfortunately I fall in to the latter category, where I just have a series of folders that have useful scripts that I have to hunt down and run when I remember, key there is remember that a problem I am facing I have already solved.&amp;nbsp; I am going to make a utility database that I will carry with me from now on.&amp;nbsp; This will be known as util, and hopefully this blog will be my repository for those scripts.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt; 
&lt;P style="LINE-HEIGHT:115%;TEXT-INDENT:0.5in;MARGIN-BOTTOM:10pt;"&gt;&lt;SPAN style="LINE-HEIGHT:115%;FONT-FAMILY:'Calibri','sans-serif';FONT-SIZE:11pt;mso-ascii-theme-font:minor-latin;mso-hansi-theme-font:minor-latin;mso-bidi-theme-font:minor-latin;"&gt;Now on to the main point of this entry, Job Statuses or more importantly how can you see the status of a job running in SQL Server Agent other than using the GUI.&amp;nbsp; Well simple enough Microsoft offers a good procedure sp_help_job that will show you along with the status information a slew of other information, in multiple result sets.&amp;nbsp; I’ll just go and capture those result sets in a table variable a select the status value that I am looking for.&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:115%;TEXT-INDENT:0.5in;MARGIN-BOTTOM:10pt;"&gt;&lt;SPAN style="LINE-HEIGHT:115%;FONT-FAMILY:'Calibri','sans-serif';FONT-SIZE:11pt;mso-ascii-theme-font:minor-latin;mso-hansi-theme-font:minor-latin;mso-bidi-theme-font:minor-latin;"&gt;Unfortunately its not that easy, you cannot insert results from a stored procedure into a temporary table or a table variable if that procedure returns multiple result sets that are different or if the first stored procedure nests other stored procedures in side it.&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;In this case sp_help_jobs does both, &lt;/SPAN&gt;&lt;SPAN style="LINE-HEIGHT:115%;FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;insert&lt;/SPAN&gt;&lt;SPAN style="LINE-HEIGHT:115%;FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt; &lt;SPAN style="COLOR:blue;"&gt;into&lt;/SPAN&gt; #tempTable&lt;SPAN style="COLOR:gray;"&gt;/&lt;/SPAN&gt;@varaibleTable &lt;SPAN style="COLOR:blue;"&gt;exec&lt;/SPAN&gt; sp_help_jobs&lt;/SPAN&gt;&lt;SPAN style="LINE-HEIGHT:115%;FONT-FAMILY:'Calibri','sans-serif';FONT-SIZE:11pt;mso-ascii-theme-font:minor-latin;mso-hansi-theme-font:minor-latin;mso-bidi-theme-font:minor-latin;"&gt; will not work. So off to plan “B”, what does the sp_help_job do?&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;In short a lot.&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;In more detail you can use the use sp_helptext procedure in the msdb database to see what sp_help_jobs is doing.&amp;nbsp; (I’ve learned a lot about SQL Server from sp_helptext!)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;use&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt; msdb&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN:0in 0in 10pt;" class=MsoNormal&gt;&lt;SPAN style="LINE-HEIGHT:115%;FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;exec&lt;/SPAN&gt;&lt;SPAN style="LINE-HEIGHT:115%;FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt; &lt;SPAN style="COLOR:maroon;"&gt;sp_helptext&lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR:maroon;"&gt;sp_help_job&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN:0in 0in 10pt;" class=MsoNormal&gt;&lt;SPAN style="mso-bidi-theme-font:minor-latin;mso-bidi-font-family:Calibri;"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Now looking through all of that code you will find that it is calling sp_verify_jobs, you pass this procedure a job name or a job id and with the correct parameters and it will return those variables verified and filled in with the missing information.&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;If you pass in job name, job name is verified and job_id will be passed out, and vice versa.&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;I haven’t spent a lot of time investigating this job but it seems to work very well and is integrated into system stored procedures so I will take it at its face value.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;use&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt; msdb&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN:0in 0in 10pt;" class=MsoNormal&gt;&lt;SPAN style="LINE-HEIGHT:115%;FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;exec&lt;/SPAN&gt;&lt;SPAN style="LINE-HEIGHT:115%;FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt; &lt;SPAN style="COLOR:maroon;"&gt;sp_helptext&lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR:maroon;"&gt;sp_verify_job_identifiers&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN:0in 0in 10pt;" class=MsoNormal&gt;&lt;SPAN style="mso-bidi-theme-font:minor-latin;mso-bidi-font-family:Calibri;"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;As we continue to look into sp_help_job it looks as if the system procedure sp_get_composite_job_info is returning the result set that I need.&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;It also returns multiple result sets so I need to dig into that procedure.&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;Inside this procedure I come across an extended stored procedure xp_sqlAgent_enum_jobs, which is returning the information in a single result set that I am looking for.&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;So with this in mind I start to write my own job information gathering proc.&lt;SPAN style="COLOR:maroon;mso-no-proof:yes;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;" class=MsoNormal&gt;&lt;SPAN style="mso-bidi-theme-font:minor-latin;mso-bidi-font-family:Calibri;"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Here it is below:&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;" class=MsoNormal&gt;&lt;SPAN style="mso-bidi-theme-font:minor-latin;mso-bidi-font-family:Calibri;"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;(Also available without commentary here: &lt;A href="http://vsteamsystemcentral.com/cs21/files/folders/steve/entry514.aspx"&gt;0002_utilis.jobs.get_job_status_sp.sql&lt;/A&gt; &lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&lt;/SPAN&gt;)&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;" class=MsoNormal&gt;&lt;SPAN style="mso-bidi-theme-font:minor-latin;mso-bidi-font-family:Calibri;"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;(You may also want the util db build script here:&lt;A href="http://vsteamsystemcentral.com/cs21/files/folders/steve/entry513.aspx"&gt; 0001_create_database_util.sql&lt;/A&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;" class=MsoNormal&gt;&lt;SPAN style="mso-bidi-theme-font:minor-latin;mso-bidi-font-family:Calibri;"&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;use&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt; util&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:green;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;--======================--&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:green;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;--Logging some basic info&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:green;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;--======================--&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;print&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt; &lt;SPAN style="COLOR:fuchsia;"&gt;@@SERVERNAME&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;print&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt; &lt;SPAN style="COLOR:fuchsia;"&gt;SUSER_NAME&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;()&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;print&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt; &lt;SPAN style="COLOR:fuchsia;"&gt;GETDATE&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;()&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;go&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:green;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;:So the code above is just some standard logging information that I like to record when my scripts run incase I’m am writing the output to a log somewhere.&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;This was something I saw Andy Leonard do in one of his presentations and I think it’s a good idea, so I’ve started to incorporate it in all my scripts.&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;This will also be a good thing to have if you have an automated deployment environment or want to have one in the future.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:green;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:green;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;-- ==Depending on your build enviomrent you may want to comment out the destructive drop below== --&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;IF&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;EXISTS&lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;SELECT&lt;/SPAN&gt; &lt;SPAN style="COLOR:gray;"&gt;*&lt;/SPAN&gt; &lt;SPAN style="COLOR:blue;"&gt;FROM&lt;/SPAN&gt; &lt;SPAN style="COLOR:green;"&gt;sys&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;.&lt;/SPAN&gt;&lt;SPAN style="COLOR:green;"&gt;objects&lt;/SPAN&gt; &lt;SPAN style="COLOR:blue;"&gt;WHERE&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:fuchsia;"&gt;OBJECT_ID&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR:red;"&gt;N'[dbo].[get_job_status_sp]'&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;)&lt;/SPAN&gt; &lt;SPAN style="COLOR:gray;"&gt;AND&lt;/SPAN&gt; &lt;SPAN style="COLOR:blue;"&gt;type&lt;/SPAN&gt; &lt;SPAN style="COLOR:gray;"&gt;in&lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR:red;"&gt;N'P'&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;,&lt;/SPAN&gt; &lt;SPAN style="COLOR:red;"&gt;N'PC'&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;))&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;DROP&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt; &lt;SPAN style="COLOR:blue;"&gt;PROCEDURE&lt;/SPAN&gt; [dbo]&lt;SPAN style="COLOR:gray;"&gt;.&lt;/SPAN&gt;[get_job_status_sp]&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;go&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;: Nothing special above except for if you do not want to script out your permissions every time you run this script you may want to comment it out so you don’t accidently remove permissions on this proc.&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;When I run this script my account is either in the sysAdmin role or I script out the permissions in a separate file.&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;create&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt; &lt;SPAN style="COLOR:blue;"&gt;procedure&lt;/SPAN&gt; dbo&lt;SPAN style="COLOR:gray;"&gt;.&lt;/SPAN&gt;get_job_status_sp&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt;@job_id &lt;SPAN style="COLOR:blue;"&gt;UNIQUEIDENTIFIER&lt;/SPAN&gt; &lt;SPAN style="COLOR:gray;"&gt;=&lt;/SPAN&gt; &lt;SPAN style="COLOR:gray;"&gt;NULL&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:gray;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt;@job_name &lt;SPAN style="COLOR:blue;"&gt;SYSNAME&lt;/SPAN&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;=&lt;/SPAN&gt; &lt;SPAN style="COLOR:gray;"&gt;NULL&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:gray;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt;@job_status &lt;SPAN style="COLOR:blue;"&gt;INT&lt;/SPAN&gt; &lt;SPAN style="COLOR:blue;"&gt;OUTPUT&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;As&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;: Notice that the procedure does not require either variable but it will need one; this is to be handled later in the script.&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;Some people like to have the comments below listed right before the create object statement so it is recorded in the system tables along with the object but not in it.&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;I like to have inside the object if I can.&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:green;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:green;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;-- =============================================== --&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:green;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;-- Author:Steve Fibich&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:green;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;-- Create date: 02/25/2010&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:green;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;-- Description: This procedure returns the status&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:green;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;-- of a job and only this value.&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;This information &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:green;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;-- is avilable from sp_help_job but the result &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:green;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;-- of that stored procedure can not be collected&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:green;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;-- into a variable or temp table.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:green;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;-- This procedure is based heavily on sp_help_job&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:green;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;-- and sp_get_composite_job_info.&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;The majority&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:green;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;-- of the code is coppied from those two stored procedures &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:green;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;--&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:green;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;-- Value&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;Description (From Books Online for SP_HELP_JOBS) &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:green;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;-- 0&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;Returns only those jobs that are not idle or suspended. &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:green;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;-- 1&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;Executing.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:green;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;-- 2&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;Waiting for thread.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:green;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;-- 3&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;Between retries.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:green;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;-- 4&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;Idle.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:green;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;-- 5&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;Suspended.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:green;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;-- 7&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;Performing completion actions.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:green;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;-- =============================================== --&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;BEGIN&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;if &lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:gray;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;((&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt;@job_id &lt;SPAN style="COLOR:gray;"&gt;is&lt;/SPAN&gt; &lt;SPAN style="COLOR:gray;"&gt;null&lt;/SPAN&gt; &lt;SPAN style="COLOR:gray;"&gt;and&lt;/SPAN&gt; @job_name &lt;SPAN style="COLOR:gray;"&gt;is&lt;/SPAN&gt; &lt;SPAN style="COLOR:gray;"&gt;null)&lt;/SPAN&gt; &lt;SPAN style="COLOR:gray;"&gt;or&lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;(&lt;/SPAN&gt;@job_id &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 style="COLOR:gray;"&gt;and&lt;/SPAN&gt; @job_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;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;BEGIN&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;SPAN style="mso-tab-count:1;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;RAISERROR&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR:red;"&gt;N'Either @job_id or @job_name is required.'&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;,&lt;/SPAN&gt;10&lt;SPAN style="COLOR:gray;"&gt;,&lt;/SPAN&gt;1&lt;SPAN style="COLOR:gray;"&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;END&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;:Above we are enforcing the caller to pass either job_id or job_name but not both, even though the procedure itself allows both variables to be null.&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;The reason to not allow both is that I do not want to get conflicting information a job_id that does not correspond to a job name, if I got that what would be executed?&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;SET&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt; &lt;SPAN style="COLOR:blue;"&gt;NOCOUNT&lt;/SPAN&gt; &lt;SPAN style="COLOR:blue;"&gt;ON&lt;/SPAN&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;DECLARE&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt; @xp_results &lt;SPAN style="COLOR:blue;"&gt;TABLE&lt;/SPAN&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:gray;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt;job_id&lt;SPAN style="mso-tab-count:4;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;UNIQUEIDENTIFIER&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 style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:gray;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt;last_run_date&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;INT&lt;/SPAN&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &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 style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:gray;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt;last_run_time&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;INT&lt;/SPAN&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &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 style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:gray;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt;next_run_date&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;INT&lt;/SPAN&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &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 style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:gray;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt;next_run_time&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;INT&lt;/SPAN&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &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 style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:gray;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt;next_run_schedule_id&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;INT&lt;/SPAN&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &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 style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:gray;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt;requested_to_run&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;INT&lt;/SPAN&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &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 style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:gray;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt;request_source&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;INT&lt;/SPAN&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &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 style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:gray;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt;request_source_id&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;sysname&lt;/SPAN&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;COLLATE&lt;/SPAN&gt; database_default &lt;SPAN style="COLOR:gray;"&gt;NULL&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:gray;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt;running&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;INT&lt;/SPAN&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &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 style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:gray;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt;current_step&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;INT&lt;/SPAN&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &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 style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:gray;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt;current_retry_attempt &lt;SPAN style="COLOR:blue;"&gt;INT&lt;/SPAN&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &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 style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:gray;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt;job_state&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;INT&lt;/SPAN&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &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 style="COLOR:green;"&gt;-- This is the value we care about!&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="mso-bidi-theme-font:minor-latin;mso-no-proof:yes;mso-bidi-font-family:Calibri;"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;:Above we are declaring a table variable to hold the values returned from the extended stored procedure.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;DECLARE&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt; @can_see_all_running_jobs &lt;SPAN style="COLOR:blue;"&gt;INT&lt;/SPAN&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;DECLARE&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt; @retval&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;INT&lt;/SPAN&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;DECLARE&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt; @category_id&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;INT&lt;/SPAN&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;DECLARE&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt; @job_id_as_char&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;VARCHAR&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;(&lt;/SPAN&gt;36&lt;SPAN style="COLOR:gray;"&gt;)&lt;/SPAN&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;DECLARE&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt; @res_valid_range &lt;SPAN style="COLOR:blue;"&gt;NVARCHAR&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;(&lt;/SPAN&gt;200&lt;SPAN style="COLOR:gray;"&gt;)&lt;/SPAN&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:green;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;-- Remove any leading/trailing spaces from parameters (except @owner_login_name)&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&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; @job_name &lt;SPAN style="COLOR:gray;"&gt;=&lt;/SPAN&gt; &lt;SPAN style="COLOR:fuchsia;"&gt;LTRIM&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR:fuchsia;"&gt;RTRIM&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;(&lt;/SPAN&gt;@job_name&lt;SPAN style="COLOR:gray;"&gt;))&lt;/SPAN&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:green;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;-- Turn [nullable] empty string parameters into NULLs&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;IF &lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:gray;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt;@job_name&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;=&lt;/SPAN&gt; &lt;SPAN style="COLOR:red;"&gt;N''&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;)&lt;/SPAN&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;SPAN style="mso-tab-count:1;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;SELECT&lt;/SPAN&gt; @job_name &lt;SPAN style="COLOR:gray;"&gt;=&lt;/SPAN&gt; &lt;SPAN style="COLOR:gray;"&gt;NULL&lt;/SPAN&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;IF &lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:gray;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;((&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt;@job_id &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 style="COLOR:gray;"&gt;OR&lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;(&lt;/SPAN&gt;@job_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 style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;BEGIN&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;EXECUTE&lt;/SPAN&gt; @retval &lt;SPAN style="COLOR:gray;"&gt;=&lt;/SPAN&gt; msdb&lt;SPAN style="COLOR:gray;"&gt;.&lt;/SPAN&gt;dbo&lt;SPAN style="COLOR:gray;"&gt;.&lt;/SPAN&gt;&lt;SPAN style="COLOR:maroon;"&gt;sp_verify_job_identifiers&lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:red;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;'@job_name'&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="COLOR:red;"&gt;'@job_id'&lt;/SPAN&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;,&lt;/SPAN&gt;@job_name &lt;SPAN style="COLOR:blue;"&gt;OUTPUT&lt;/SPAN&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;,&lt;/SPAN&gt;@job_id&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;OUTPUT&lt;/SPAN&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;END&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:green;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;--select @job_id&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:green;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;SPAN style="mso-bidi-theme-font:minor-latin;mso-no-proof:yes;mso-bidi-font-family:Calibri;"&gt;:Calling sp_verify_job_identifiers gaurantees that we have a valid job id, it will over right our @job_id with a valid value if we only had a job_name and if we had a job_id it will overwrite it with the same value and populate the @job_name variable.&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:green;mso-no-proof:yes;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:green;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&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; @can_see_all_running_jobs &lt;SPAN style="COLOR:gray;"&gt;=&lt;/SPAN&gt; &lt;SPAN style="COLOR:fuchsia;"&gt;ISNULL&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR:fuchsia;"&gt;IS_SRVROLEMEMBER&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR:red;"&gt;N'sysadmin'&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;),&lt;/SPAN&gt; 0&lt;SPAN style="COLOR:gray;"&gt;)&lt;/SPAN&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;IF &lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;(&lt;/SPAN&gt;@can_see_all_running_jobs &lt;SPAN style="COLOR:gray;"&gt;=&lt;/SPAN&gt; 0&lt;SPAN style="COLOR:gray;"&gt;)&lt;/SPAN&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;BEGIN&lt;/SPAN&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;SELECT&lt;/SPAN&gt; @can_see_all_running_jobs &lt;SPAN style="COLOR:gray;"&gt;=&lt;/SPAN&gt; &lt;SPAN style="COLOR:fuchsia;"&gt;ISNULL&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR:fuchsia;"&gt;IS_MEMBER&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="COLOR:red;"&gt;N'SQLAgentReaderRole'&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;),&lt;/SPAN&gt; 0&lt;SPAN style="COLOR:gray;"&gt;)&lt;/SPAN&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;END&lt;/SPAN&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="mso-bidi-theme-font:minor-latin;mso-no-proof:yes;mso-bidi-font-family:Calibri;"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;:Above we are checking to see if the user has the appropriate permissions to access sqlAgent job information. This was being done in the system stored procedures, and it makes good sense, so I figured I should continue this security practice in my own proc.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;DECLARE&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt; @job_owner&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;sysname&lt;/SPAN&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&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; @job_owner &lt;SPAN style="COLOR:gray;"&gt;=&lt;/SPAN&gt; &lt;SPAN style="COLOR:fuchsia;"&gt;SUSER_SNAME&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;()&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;insert&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt; @xp_results&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;execute&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt; &lt;SPAN style="COLOR:blue;"&gt;master&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;.&lt;/SPAN&gt;dbo&lt;SPAN style="COLOR:gray;"&gt;.&lt;/SPAN&gt;&lt;SPAN style="COLOR:maroon;"&gt;xp_sqlagent_enum_jobs&lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt;@can_see_all_running_jobs&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:gray;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt;@job_owner&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:gray;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt; @job_id&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&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; @job_status&lt;SPAN style="COLOR:gray;"&gt;=&lt;/SPAN&gt;job_state &lt;SPAN style="COLOR:blue;"&gt;from&lt;/SPAN&gt; @xp_results&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;SPAN style="mso-bidi-theme-font:minor-latin;mso-no-proof:yes;mso-bidi-font-family:Calibri;"&gt;:Finally we call the xp_sqlAgent_enum jobs with the appriopriate parmaters and return the result set into the @xp_results table variable and assign the value for the job_state int othe @job_status variable to be outputed by this proc.&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;END&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;GO&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;declare&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt; @job_status &lt;SPAN style="COLOR:blue;"&gt;int&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;execute&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt; util&lt;SPAN style="COLOR:gray;"&gt;.&lt;/SPAN&gt;dbo&lt;SPAN style="COLOR:gray;"&gt;.&lt;/SPAN&gt;get_job_status_sp&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt;@job_name&lt;SPAN style="COLOR:gray;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="COLOR:red;"&gt;'SlowlyRunningJob'&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:gray;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt;@job_status &lt;SPAN style="COLOR:gray;"&gt;=&lt;/SPAN&gt;@job_status &lt;SPAN style="COLOR:blue;"&gt;OUTPUT&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN:0in 0in 10pt;" class=MsoNormal&gt;&lt;SPAN style="LINE-HEIGHT:115%;FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;select&lt;/SPAN&gt;&lt;SPAN style="LINE-HEIGHT:115%;FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt; @job_status&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN:0in 0in 10pt;" class=MsoNormal&gt;&lt;SPAN style="mso-bidi-theme-font:minor-latin;mso-no-proof:yes;mso-bidi-font-family:Calibri;"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;:Lastly we have a go statement to separate out our procedure logic and call the procedure we just called with a job named slowlyRunnignJob.&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;This job has the following code in it. &lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;declare&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt; @counter &lt;SPAN style="COLOR:blue;"&gt;int&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;set&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt; @counter &lt;SPAN style="COLOR:gray;"&gt;=&lt;/SPAN&gt;0&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;while&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt; @counter &lt;SPAN style="COLOR:gray;"&gt;&amp;lt;&lt;/SPAN&gt; 10&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;BEGIN&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;SPAN style="mso-tab-count:1;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;waitfor&lt;/SPAN&gt; &lt;SPAN style="COLOR:blue;"&gt;delay&lt;/SPAN&gt; &lt;SPAN style="COLOR:red;"&gt;'00:0:01'&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;SPAN style="mso-tab-count:1;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR:blue;"&gt;set&lt;/SPAN&gt; @counter&lt;SPAN style="COLOR:gray;"&gt;=&lt;/SPAN&gt;@counter&lt;SPAN style="COLOR:gray;"&gt;+&lt;/SPAN&gt;1&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN:0in 0in 10pt;" class=MsoNormal&gt;&lt;SPAN style="LINE-HEIGHT:115%;FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;END&lt;/SPAN&gt;&lt;SPAN style="mso-bidi-theme-font:minor-latin;mso-no-proof:yes;mso-bidi-font-family:Calibri;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN:0in 0in 10pt;" class=MsoNormal&gt;&lt;SPAN style="mso-bidi-theme-font:minor-latin;mso-no-proof:yes;mso-bidi-font-family:Calibri;"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&lt;/SPAN&gt;(I did not include this as a file so if you want it grab it here and stick it into a sql job for testing.)&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN:0in 0in 10pt;" class=MsoNormal&gt;&lt;SPAN style="LINE-HEIGHT:115%;FONT-FAMILY:'Courier New';FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN:0in 0in 10pt;" class=MsoNormal&gt;&lt;SPAN style="mso-bidi-theme-font:minor-latin;mso-no-proof:yes;mso-bidi-font-family:Calibri;"&gt;&lt;FONT size=3 face=Calibri&gt;So you may be saying to yourself, well that’s great and now you can get a job status value into a varaible, but really what is the point. &lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&lt;/SPAN&gt;Did you just break apart system stored procedures and cherry pick the one value you want&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;and stick into your proc for some very limited purpose.&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;The answer is more or less yes, but the purpose is bigger than just to retrive that one value.&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;The purpose is to allow you to check job status programtically and allow that programtic checking to do something with the status.&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;This will allow us to create a SQL Server Agent job calling process that can wait for the job to stop prior to calling the next step, but this is the subject of another post.&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;img src="http://vsteamsystemcentral.com/cs21/aggbug.aspx?PostID=512" width="1" height="1"&gt;</description><category domain="http://vsteamsystemcentral.com/cs21/blogs/steve_fibich/archive/tags/Database+Design/default.aspx">Database Design</category><category domain="http://vsteamsystemcentral.com/cs21/blogs/steve_fibich/archive/tags/T-SQL/default.aspx">T-SQL</category><category domain="http://vsteamsystemcentral.com/cs21/blogs/steve_fibich/archive/tags/util+db/default.aspx">util db</category></item><item><title>My blog is moving!</title><link>http://vsteamsystemcentral.com/cs21/blogs/timbenninghoff/archive/2010/02/08/my-blog-is-moving.aspx</link><pubDate>Tue, 09 Feb 2010 03:10:00 GMT</pubDate><guid isPermaLink="false">d291d4df-cf3d-4686-b1b1-8a0a96a3a0a7:511</guid><dc:creator>timbenninghoff</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;Yup, you read the title right.&amp;nbsp; My blog is going to be moving.&amp;nbsp; For a number of different reasons it's time for me to strike out on my own, so I'm following Brent Ozar's excellent &lt;a href="http://www.brentozar.com/archive/2008/12/how-to-start-a-technical-blog/" target="_blank"&gt;How To Start a Blog&lt;/a&gt; series to make that migration happen.&amp;nbsp; One of those reasons is that my wife has given me a project of migrating her ftp-hosted Blogger blog over to WordPress.&amp;nbsp; She's got scores of readers and I'd like to make that transition as seamless as possible for them.&amp;nbsp; And, it's against my nature to make changes to production without having done some sort of test, so my migration of my own blog to WordPress will be a good test run that, while not identical, will give me some basis of understanding for when I take the leap with her blog.&lt;/p&gt;&lt;p&gt;&amp;nbsp;I've also known that I have to move this year, and having this imminent change hanging over me was just another impediment to sitting down and getting my thoughts out, and getting to work on all of the other home tech projects I want to do this year.&amp;nbsp; It's time for action, I sez.&lt;/p&gt;&lt;p&gt;I'll make a more official announcement once I'm ready to declare my new home, but it shouldn't be to hard to find the new home if you'd like to watch the messy metamorphosis.&amp;nbsp; &lt;br&gt;&lt;/p&gt;&lt;img src="http://vsteamsystemcentral.com/cs21/aggbug.aspx?PostID=511" width="1" height="1"&gt;</description><category domain="http://vsteamsystemcentral.com/cs21/blogs/timbenninghoff/archive/tags/Blogging/default.aspx">Blogging</category></item><item><title>Why Microsoft gets a bad name with Support (part 2 - no you cannot escalate)</title><link>http://vsteamsystemcentral.com/cs21/blogs/brian_johnston/archive/2010/01/27/why-microsoft-gets-a-bad-name-with-support-part-2-the-hand-off.aspx</link><pubDate>Wed, 27 Jan 2010 20:34:00 GMT</pubDate><guid isPermaLink="false">d291d4df-cf3d-4686-b1b1-8a0a96a3a0a7:510</guid><dc:creator>brian</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;So apparently my request to have the issue promoted to the next level of support was denied, and once again, the answer is to tell the business owner (essentially) jump through hoops because a data issue can't be fixed.&amp;nbsp;&amp;nbsp; Let me point out another frustration, the over-politeness that feels almost belittling; like they're talking to a 5 year old or something.&amp;nbsp;&amp;nbsp; If you're 'truly sorry' then fix the problem!&amp;nbsp;&amp;nbsp; If this was Ray Ozzie or some other CXO at Microsoft I'm sure this would've been fixed by now.&lt;br&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;---&lt;/p&gt;
&lt;p class="MsoNormal" style="text-align:justify;line-height:12pt;"&gt;&lt;span style="font-size:10pt;font-family:'Arial','sans-serif';"&gt;Hello Brian,&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal" style="line-height:12pt;"&gt;&lt;span style="font-size:10pt;font-family:'Arial','sans-serif';"&gt;&amp;nbsp;Thank
you for replying to us at Microsoft Office Live Workspace Support. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal" style="line-height:12pt;"&gt;&lt;span style="font-size:10pt;font-family:'Arial','sans-serif';"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;My
name is Akash XXXXX and I have updated Service Request # 1121112775, which was
created to track your concern.&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:'Arial','sans-serif';"&gt;&amp;nbsp;I am aware of your concern that you
are unable to share with a particular email ID. Also, you would like to hear
personally from the Next level team and the team above. I realize the
importance of your concern and I would provide you with the information.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-weight:bold;background-color:Yellow;font-family:'Arial','sans-serif';"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;Brian, I am sorry to inform you
that, we will not be able to escalate the case further to Next level or the
team above&lt;/span&gt; as we have received the update from our Next level team to tell you
that the concern is with the particular email ID. Also, before providing you
with the resolution we have done enough troubleshooting and tried to resolve
the concern but found out that the problem is with the particular email ID.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-weight:bold;background-color:Yellow;font-family:'Arial','sans-serif';"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;Additionally, as an alternative I
would suggest you to use another email ID to share workspace with the user so
that you do not face any problem while sharing.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:'Arial','sans-serif';"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;Once again, I truly apologize that
we were not able to provide you with an experience that was completely
satisfactory to you. While I realize that only our future interactions can
restore your complete confidence in us, I want to assure you that your
experience was unusual and is not indicative of the quality service Microsoft
Office Live is capable of providing. Microsoft Office Live intention is to
provide our customers with the best products and customer experience that is
both satisfying and enjoyable.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:'Arial','sans-serif';"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;For your convenience, our support
staff is available 24 hours a day, 7 days a week. If you have additional
questions, concerns or need further assistance, please be sure not to change the
subject line while replying to this email&amp;nbsp;so that we can urgently address
any remaining concerns. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:'Arial','sans-serif';"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;You may be selected to receive a
survey. Your feedback is valuable to us as we are very interested in hearing
about your support experience. Should you receive a survey, we appreciate you
taking the time to respond.&lt;br&gt;
&lt;br&gt;
Have a great day, Brian!&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&lt;br&gt;
Regards, &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal" style="line-height:12pt;"&gt;&lt;span style="font-size:10pt;font-family:'Arial','sans-serif';"&gt;Akash XXXX&lt;br&gt;
Microsoft Office Live Workspace Support&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&amp;nbsp;
&lt;img src="http://vsteamsystemcentral.com/cs21/aggbug.aspx?PostID=510" width="1" height="1"&gt;</description><category domain="http://vsteamsystemcentral.com/cs21/blogs/brian_johnston/archive/tags/Industry+Problems/default.aspx">Industry Problems</category></item><item><title>Why Microsoft gets a bad name with Support</title><link>http://vsteamsystemcentral.com/cs21/blogs/brian_johnston/archive/2010/01/27/why-microsoft-gets-a-bad-name-with-support.aspx</link><pubDate>Wed, 27 Jan 2010 13:27:00 GMT</pubDate><guid isPermaLink="false">d291d4df-cf3d-4686-b1b1-8a0a96a3a0a7:509</guid><dc:creator>brian</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;First off, know that I love all things Microsoft.&amp;nbsp;&amp;nbsp; I believe they are a great company and are often put under a microscope and blamed for things because they are successful and many people out there just don't want that for various reasons.&lt;/p&gt;

&lt;p&gt;But what I wanted to write about today is where they are truly dropping the ball and my hope is that someone here in American Microsoft will see this and route it through the proper channels so that not only is the problem addressed, but that whoever is in charge of overseas support gets the message that 'I am unable to help you' is an unacceptable answer here in America, its the equivalent of saying 'I am unwilling to help you' in my mind.&amp;nbsp;&amp;nbsp; An acceptable answer may be 'We can't help you at this time unless your willing to pay $X/hr or you can wait until 2nd quarter', but 'too bad' doesn't fly.&lt;/p&gt;

&lt;p&gt;So if you haven't used it, Microsoft Office Live is great!&amp;nbsp; Definitely check it out! &amp;nbsp; It's a great way to get 'Share Point' like features for free along with a free web site that even my 7 year old daughter could design. &amp;nbsp; I really mean that, and these just are not the cheesy 'front-page' web-sites you may be thinking about, these are professional looking sites that are extensible by developers such as ourselves but simple enough for the less than knowledgeable!&amp;nbsp; Plus there are many other great tools/features in Office Live.&lt;br&gt;&lt;/p&gt;

&lt;p&gt;So here's the problem. &amp;nbsp; The web site I made for our church turned out great and I had been selling the church staff on using the 'Workspace' feature to upload and share their documents with for collaboration; a hard sell because like most companies, Outlook is the CMS. &amp;nbsp; Regardless, still got them going on it, but one of the pastors was unable to be added as an editor (or viewer) to any workspace. &amp;nbsp; I started a trouble ticket and after several emails back and forth their answer was 'we can't fix it, sorry'.&lt;/p&gt;

&lt;p&gt;Now besides the fact that the 'wording' of these emails is horrible, which I can get past because I know these are just Indian work farms of folks who can barely speak English and work off of a script, I can't get past that they don't seem to understand American work-ethic or the American way.&amp;nbsp;&amp;nbsp;&amp;nbsp; There is no such thing as 'can not fix' for something that is obviously a data issue (since several other users don't have an issue).&amp;nbsp;&amp;nbsp; The last thing the owner of a company (or the equivalent in this case) want to hear is 'nope, sorry, can't fix, oh well, make another user name and password you'll need to track so you can do what you want to do'.&amp;nbsp;&amp;nbsp; America got to where she is by the 'can-do' people that have made it this great place; we don't accept anything less.&lt;br&gt;&lt;/p&gt;

&lt;p&gt;It's this type of 'I repro'd the problem, and you're right, it doesn't work, too bad' is what drives people to use Google equivalents.&amp;nbsp;&amp;nbsp; Not that their support is any better, but in many cases, all it takes is a single issue like this for people to feed into the herd mentality.&lt;/p&gt;

&lt;p&gt;The other thing that bothered me was them resetting the passwords on two accounts without first giving us a heads up.&amp;nbsp;&amp;nbsp; Pastor will probably come in today unable to access their email or update the web site and not know why (since the alternate email is an email account they might not check until later today).&lt;/p&gt;&lt;p&gt;And let me be clear, I know this isn't the fault of Ranju, he's just doing his job and what he's told, the problem is with the policies and practices of the support team.&lt;br&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;-------------&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:'Arial','sans-serif';"&gt;Hello
Brian,&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="font-size:10pt;font-family:'Verdana','sans-serif';"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:'Arial','sans-serif';"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="font-size:10pt;font-family:'Verdana','sans-serif';"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:'Arial','sans-serif';"&gt;Thank
you for writing back to Microsoft Office Live Workspace Support. My name is
Ranju XXXXXX and I am working on the Service Request # 1121112775, which was
created to track your concern related to sharing workspace with the email ID 'xyz@xyz.net'&lt;span&gt;&lt;/span&gt;. &lt;/span&gt;&lt;span style="font-size:10pt;font-family:'Verdana','sans-serif';"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:'Arial','sans-serif';"&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:'Arial','sans-serif';"&gt;I
have accessed your Microsoft Office Live Workspace account associated with&lt;/span&gt;&lt;span style="font-size:10pt;font-family:'Arial','sans-serif';"&gt; 'xyz@xyz.net' (user having problem)&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:10pt;font-family:'Arial','sans-serif';"&gt; as well as the account
associated with&lt;/span&gt;&lt;span style="font-size:10pt;font-family:'Arial','sans-serif';"&gt; 'xyz@xyz.net'&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:10pt;font-family:'Arial','sans-serif';"&gt;&lt;span style="color:black;"&gt; (Office Live admin/owner account). I have checked all the features of
these accounts. I found that there is a problem with the &lt;/span&gt;Microsoft
Office Live Workspace account of the email ID&lt;/span&gt;&lt;span style="font-size:10pt;font-family:'Arial','sans-serif';"&gt; 'xyz@xyz.net'&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:10pt;font-family:'Arial','sans-serif';"&gt;
which is the reason why you are unable to share it with the email ID&lt;/span&gt;&lt;span style="font-size:10pt;font-family:'Arial','sans-serif';"&gt; 'xyz@xyz.net'&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:10pt;font-family:'Arial','sans-serif';"&gt;. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;span style="font-family:'Arial','sans-serif';"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:'Arial','sans-serif';"&gt;We
have investigated this problem along with our Next level team. Based on the
information provided by our Next level team, I am sorry to inform you that, you
will not be able to share your Workspace with this particular email ID&amp;nbsp;&lt;/span&gt;&lt;span style="font-size:10pt;font-family:'Arial','sans-serif';"&gt; 'xyz@xyz.net'&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:10pt;font-family:'Arial','sans-serif';"&gt;&lt;span style="background-color:Yellow;font-weight:bold;"&gt;. I would request
you to use another email ID to share Workspace with the user.&lt;/span&gt;&lt;br&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:'Arial','sans-serif';"&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:'Arial','sans-serif';"&gt;We
sincerely apologize for the inconvenience you are facing because of this issue.
We appreciate your cooperation and patience as we moved ahead investigating the
issue. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;span style="font-family:'Arial','sans-serif';"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNoSpacing" style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:'Arial','sans-serif';"&gt;I am sending two
reset password links of the sign in Windows Live IDs&lt;/span&gt;&lt;span style="font-size:10pt;font-family:'Arial','sans-serif';"&gt; 'xyz@xyz.net' (user with problem)&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:10pt;font-family:'Arial','sans-serif';"&gt;
and&amp;nbsp;&lt;/span&gt;&lt;span style="font-size:10pt;font-family:'Arial','sans-serif';"&gt; 'xyz@xyz.net'&lt;span&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:10pt;font-family:'Arial','sans-serif';"&gt;&lt;span&gt;&lt;/span&gt;(Office Live owner/administrator) to
your alternate email address&lt;/span&gt;&lt;span style="font-size:10pt;font-family:'Arial','sans-serif';"&gt; 'xyz@xyz.net'&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:10pt;font-family:'Arial','sans-serif';"&gt;.
Check the inbox and junk folder of the email account of&lt;/span&gt;&lt;span style="font-size:10pt;font-family:'Arial','sans-serif';"&gt; 'xyz@xyz.net'&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:10pt;font-family:'Arial','sans-serif';"&gt; and reset the password within 24
hours. The reset password link will expire after 24 hours. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNoSpacing" style="margin:0in 0in 0.0001pt;"&gt;&lt;span&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNoSpacing" style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:'Arial','sans-serif';"&gt;Please note that the
first reset email that you receive is for the Windows Live ID&lt;/span&gt;&lt;span style="font-size:10pt;font-family:'Arial','sans-serif';"&gt; 'xyz@xyz.net'&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:10pt;font-family:'Arial','sans-serif';"&gt;. Use the first reset
password email for resetting the password of '&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:10pt;font-family:'Arial','sans-serif';"&gt; 'xyz@xyz.net'&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:10pt;font-family:'Arial','sans-serif';"&gt;&lt;span&gt;&lt;/span&gt;.
The second reset password is for Windows Live ID&amp;nbsp;&lt;/span&gt;&lt;span style="font-size:10pt;font-family:'Arial','sans-serif';"&gt; 'xyz@xyz.net'&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:10pt;font-family:'Arial','sans-serif';"&gt;&lt;span&gt;&lt;/span&gt;.
In addition, you can also reset the password of&lt;/span&gt;&lt;span style="font-size:10pt;font-family:'Arial','sans-serif';"&gt; 'xyz@xyz.net'&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:10pt;font-family:'Arial','sans-serif';"&gt;&lt;span&gt;
&lt;/span&gt;from your Microsoft Office Live Small Business account as well. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNoSpacing" style="margin:0in 0in 0.0001pt;"&gt;&lt;span&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;span&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNoSpacing" style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:'Arial','sans-serif';"&gt;We appreciate your
input and involvement in Microsoft Office Live Workspace service. Microsoft
Office Live Workspace service is in its initial developing state (i.e. in Beta
period) and there are lot of enhancements and applications/features yet to be
introduced. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNoSpacing" style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:'Arial','sans-serif';"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNoSpacing" style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:'Arial','sans-serif';"&gt;I would suggest you
to submit a request as a &lt;/span&gt;&lt;span style="font-size:10pt;font-family:'Arial','sans-serif';"&gt;feedback &lt;/span&gt;&lt;span style="font-size:10pt;font-family:'Arial','sans-serif';"&gt;by visiting &lt;span&gt;&lt;span style="text-decoration:none;"&gt;Feedback for
Office Live Workspace Beta&lt;/span&gt;&lt;/span&gt;, so that it is considered when
Microsoft Office Live Workspace upgrade takes place.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNoSpacing" style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:'Arial','sans-serif';"&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNoSpacing" style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:'Arial','sans-serif';"&gt;Please accept my
apologies for not being able to assist you fully. Thank you for patience and
understanding on this matter.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNoSpacing" style="margin:0in 0in 0.0001pt;"&gt;&amp;nbsp;&lt;span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:'Arial','sans-serif';"&gt;For
your convenience, our support staff is available 24 hours a day, 7 days a week.
If you have additional questions, concerns or need further assistance, please
be sure not to change the subject line so that we can urgently address any
remaining concerns.&amp;nbsp; &lt;/span&gt;&lt;span style="font-size:10pt;font-family:'Verdana','sans-serif';"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:'Arial','sans-serif';"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="font-size:10pt;font-family:'Verdana','sans-serif';"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:'Arial','sans-serif';"&gt;You
may be selected to receive a survey. Your feedback is valuable to us as we are
very interested in hearing about your support experience. Should you receive a
survey, we appreciate you taking the time to respond. &lt;/span&gt;&lt;span style="font-size:10pt;font-family:'Verdana','sans-serif';"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:'Arial','sans-serif';"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="font-size:10pt;font-family:'Verdana','sans-serif';"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:'Arial','sans-serif';"&gt;Best
Regards, &lt;/span&gt;&lt;span style="font-size:10pt;font-family:'Verdana','sans-serif';"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:'Arial','sans-serif';"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="font-size:10pt;font-family:'Verdana','sans-serif';"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:'Arial','sans-serif';"&gt;Ranju XXXX&lt;/span&gt;&lt;span style="font-size:10pt;font-family:'Verdana','sans-serif';"&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:'Arial','sans-serif';"&gt;Microsoft
Office Live Workspace Support&lt;/span&gt;&lt;/p&gt;

&amp;nbsp;&lt;img src="http://vsteamsystemcentral.com/cs21/aggbug.aspx?PostID=509" width="1" height="1"&gt;</description></item><item><title>PowerShell Function Gotcha</title><link>http://vsteamsystemcentral.com/cs21/blogs/timbenninghoff/archive/2010/01/26/powershell-function-gotcha.aspx</link><pubDate>Wed, 27 Jan 2010 03:34:00 GMT</pubDate><guid isPermaLink="false">d291d4df-cf3d-4686-b1b1-8a0a96a3a0a7:508</guid><dc:creator>timbenninghoff</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;In a renewed effort to read one tech book a month in 2010, I've restarted Bruce Payette's &lt;a href="http://www.manning.com/payette/" target="_blank"&gt;Windows PowerShell In Action&lt;/a&gt; just as I've been using PowerShell to solve a problem at work.&amp;nbsp; I was attempting to use a &lt;a href="http://blog.stpworks.com/archive/2009/06/08/sending-e-mail-from-powershell-v1.0.aspx" target="_blank"&gt;SendEmail&lt;/a&gt; function I found on a blog, and when I tried to call the function like this:&lt;/p&gt;&lt;p&gt;&amp;nbsp;SendEmail("someaddress@someplace.com","Someaddress@someplace.com","This is a subject","This is the body of the email");&lt;/p&gt;&lt;p&gt;I got the following error:&lt;/p&gt;&lt;blockquote&gt;&lt;blockquote&gt;&lt;p&gt;Exception setting "From": "Cannot convert the "System.Object[]" value of type "System.Object[]" to type "System.Net.Mail.MailAddress"."&lt;br&gt;At C:\PowerShell\SendEmailTest.ps1:15 char:10&lt;br&gt;+&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $msg. &amp;lt;&amp;lt;&amp;lt;&amp;lt; From = $From&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; + CategoryInfo&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; : InvalidOperation: (:) [], RuntimeException&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; + FullyQualifiedErrorId : PropertyAssignmentException&lt;br&gt;&lt;br&gt;Exception calling "Add" with "1" argument(s): "The parameter 'addresses' cannot be an empty string.&lt;br&gt;Parameter name: addresses"&lt;br&gt;At C:\PowerShell\SendEmailTest.ps1:26 char:20&lt;br&gt;+&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $msg.To.Add &amp;lt;&amp;lt;&amp;lt;&amp;lt; ($singleAddress)&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; + CategoryInfo&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; : NotSpecified: (:) [], MethodInvocationException&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; + FullyQualifiedErrorId : DotNetMethodException&lt;br&gt;&lt;br&gt;Exception calling "Send" with "1" argument(s): "A from address must be specified."&lt;br&gt;At C:\PowerShell\SendEmailTest.ps1:56 char:17&lt;br&gt;+&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $client.Send &amp;lt;&amp;lt;&amp;lt;&amp;lt; ($msg)&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; + CategoryInfo&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; : NotSpecified: (:) [], MethodInvocationException&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; + FullyQualifiedErrorId : DotNetMethodException &lt;/p&gt;&lt;/blockquote&gt;&lt;/blockquote&gt;&lt;p&gt;&amp;nbsp;The parameter 'addresses' is an empty string?&amp;nbsp; How is that possible?&amp;nbsp; I clearly entered someaddress@someplace.com which is most definitely not an empty string.&amp;nbsp; Fortunately, I read about this PowerShell function gotcha in Mr. Payette's book on page 183, where goes on to describe things like PowerShell looking at the contents of parentheses as an expression and very smart people being tripped up by this.&lt;/p&gt;&lt;p&gt;To make a long story short, I should have called the function with the arguments separated by spaces, like:&lt;/p&gt;&lt;p&gt;&amp;nbsp;SendEmail "someaddress@someplace.com" "Someaddress@someplace.com" "This is a 
subject" "This is the body of the email";&lt;/p&gt;&lt;p&gt;I'll take this opportunity to plug the book again.&amp;nbsp; It's little pieces of advice like this that have saved me a ton of time as I've learned PowerShell.&lt;br&gt;&lt;/p&gt;&lt;img src="http://vsteamsystemcentral.com/cs21/aggbug.aspx?PostID=508" width="1" height="1"&gt;</description><category domain="http://vsteamsystemcentral.com/cs21/blogs/timbenninghoff/archive/tags/PowerShell/default.aspx">PowerShell</category></item><item><title>2010 Professional Goals</title><link>http://vsteamsystemcentral.com/cs21/blogs/timbenninghoff/archive/2010/01/18/2010-professional-goals.aspx</link><pubDate>Tue, 19 Jan 2010 02:26:00 GMT</pubDate><guid isPermaLink="false">d291d4df-cf3d-4686-b1b1-8a0a96a3a0a7:505</guid><dc:creator>timbenninghoff</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;Time to make my professional goals again for the new year.&amp;nbsp; In conjunction with listing my new goals, I'll also talk about some of the goals for last year and how I fared.&lt;/p&gt;&lt;p&gt;&lt;b&gt;Certification&lt;/b&gt;:&amp;nbsp; Pass exam 70-453 in order to earn my MCITP: Database Administrator 2008.&amp;nbsp; &lt;b&gt;Bonus Goal&lt;/b&gt;:&amp;nbsp; Pick another certification and take at least one exam for it.&amp;nbsp; Server Admin?&amp;nbsp; BI Developer?&amp;nbsp; Database Developer??&lt;br&gt;&lt;/p&gt;&lt;p&gt;Last year:&amp;nbsp; I reached my goal of getting my MCITP: Database Administrator certification.&lt;/p&gt;&lt;p&gt;&lt;b&gt;Blogging&lt;/b&gt;:&amp;nbsp; Make at least one blog post a week.&amp;nbsp; Move blog to a new site.&lt;/p&gt;&lt;p&gt;Last year:&amp;nbsp; Didn't quite make the one blog post a week.&amp;nbsp; I'm hoping to do better this year, starting now.&amp;nbsp; It's only 52 posts, right?&lt;br&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;Reading&lt;/b&gt;:&amp;nbsp; One technology book a month. &lt;/p&gt;&lt;p&gt;Last year:&amp;nbsp; Man, didn't hit this one either.&amp;nbsp; Uh oh, I don't like where this review of last year is headed...&lt;/p&gt;&lt;p&gt;&lt;b&gt;Technology&lt;/b&gt;:&amp;nbsp; Focus on learning Powershell, SSIS, and SSAS.&lt;/p&gt;&lt;p&gt;Last year:&amp;nbsp; Undefineable goal, but my early enthusiasm for Powershell really kind of died out as I didn't have any places to apply it at work.&amp;nbsp; 2010 is starting out very differently, and I've already developed some automation scripts with Powershell for work, and I'm starting to recommend it for certain things to our developers as well.&lt;/p&gt;&lt;p&gt;&lt;b&gt;Scripting&lt;/b&gt;:&amp;nbsp; Write 1 script a week for my toolbox. &lt;/p&gt;&lt;p&gt;Last year:&amp;nbsp; Tried this goal, and, by my count, I ended up with 74 new scripts, in both T-SQL and Powershell, that make my job easier.&amp;nbsp; Hurray!&amp;nbsp; I got one.&lt;/p&gt;&lt;p&gt;&lt;b&gt;Learning&lt;/b&gt;: Attend 6 of the monthly local SQL Server user group meetings this year.&amp;nbsp; Attend PASS Summit.&lt;br&gt;&lt;/p&gt;&lt;p&gt;Last year:&amp;nbsp; Yup, I did manage to attend my goal of 1 user group meeting last year, and I also attended the PASS Summit.&lt;/p&gt;&lt;p&gt;&lt;b&gt;Volunteer&lt;/b&gt;:&amp;nbsp; Donate some of my time to PASS, or to my local SQL Server User Group.&amp;nbsp; I'm already slated to volunteer at &lt;a href="http://www.sqlsaturday.com/31/eventhome.aspx" target="_blank"&gt;SQL Saturday 31 in Chicago&lt;/a&gt;.&lt;/p&gt;&lt;p&gt;Last year:&amp;nbsp; Didn't make it a goal, so this one's a new one. &lt;br&gt;&lt;/p&gt;&lt;img src="http://vsteamsystemcentral.com/cs21/aggbug.aspx?PostID=505" width="1" height="1"&gt;</description><category domain="http://vsteamsystemcentral.com/cs21/blogs/timbenninghoff/archive/tags/Goals/default.aspx">Goals</category></item><item><title>How do we use SQL Server?</title><link>http://vsteamsystemcentral.com/cs21/blogs/timbenninghoff/archive/2009/12/09/how-do-we-use-sql-server.aspx</link><pubDate>Thu, 10 Dec 2009 01:59:00 GMT</pubDate><guid isPermaLink="false">d291d4df-cf3d-4686-b1b1-8a0a96a3a0a7:503</guid><dc:creator>timbenninghoff</dc:creator><slash:comments>1</slash:comments><description>&lt;p&gt;I was tagged in a &lt;a href="http://facility9.com/2009/12/02/how-do-you-use-sql-server" target="_blank"&gt;recent post by Jeremiah Peschka&lt;/a&gt; asking how we use SQL Server.&amp;nbsp; Jeremiah has uttered that words that compel me to reveal my true identity, despite the great risk I take in doing so.&amp;nbsp; Fear not, for the true consciousness of the one who identifies himself as Tim Benninghoff is safe, and, due to his cooperative nature, has been granted access to our vast Yithian libraries to occupy his time while I borrow his body.&lt;/p&gt;&lt;p&gt;This SQL Server, as far as I have been able to discover, is a data manipulation system of great power, but fraught with great danger for the uninitiated.&amp;nbsp; In the current organizational construct to which I have attached this
Tim form in order to learn more about this SQL Server, I have found that it is primarily used as the platform by which
Independent Software Vendors, under the ruse of providing something
called 'solutions', unleash their torment upon the guardians of
information of humanity, which your age has called DBAs.&amp;nbsp; Some of these 'ISVs' do seem to have in their possession a true, complete, unaltered copy of the manuscript known as Books Online, and access to the further writings of SQL Server's technological priesthood, known as MVPs, but I find that the vast majority of these ISVs seem to have based their machinations on apocryphal, if not outright heretical, knowledge compilations of SQL Server.&amp;nbsp; In a query to the Tim consciousness, he suggests that ignorance drives their decisions.&amp;nbsp; From the discomfort and distractions they inflict upon me in this Tim form, I am forced to disagree with him and attribute their actions to malice of the darkest and most sinister nature.&amp;nbsp; Perhaps DBAs will one day unlock the secrets of time, and be able to transport their consciousness in order to escape the ISVs, much as we have done to escape our destruction at the hands of the flying polyps.&lt;br&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;Another thought framework, which I have heard referred to as the Frame of the Main, seems to perform most of the data support for this organizational construct, also referred to as a company by the other humans amongst whom I walk.&amp;nbsp; However, I have noticed that a transition of certain functions away from the Frame of the Main to SQL Server seems to be under way.&amp;nbsp; This transition has been a difficult one, as former practitioners of the COBOL pictograms move their domain knowledge into the much revered relational storage archetype of SQL Server.&amp;nbsp; Of note, an electronic library exists, referred to by the humans here as the Data Warehouse, that collects information from this Frame of the Main and transfers it to the Data Warehouse.&amp;nbsp; The curious and remarkable thing is that the SQL Agent is the primary mechanism by which this data movement, known as ETL, is performed.&amp;nbsp; These SQL practitioners have found ways to apply the power of the SQL Agent that I had not thought possible!&lt;/p&gt;&lt;p&gt;&amp;nbsp;As if the onslaught of the SQL Server ISVs were not enough, a great ravening beast, fearfully referred to as The Oracle, appears to be hatching some arcane and nefarious plan to increase its dominion over the company, employing its own ISVs to champion its cause.&amp;nbsp; The Oracle's plan seems to be working, as even now this Tim form is being instructed to assist in transporting data to the systems in The Oracle's web of influence.&lt;/p&gt;&lt;p&gt;&amp;nbsp;All is not gloom for me in this Tim form, as we have begun the installation of the latest universal understanding, SQL Server 2008, and have nearly retired all instances of the reliable, but ancient in the information techology timeframe, SQL Server 2000.&amp;nbsp; I look for ways to employ some of its new features such as PowerShell support, Central Management Server, Policy Based Management, and Management Data Warehouse to the greater glory of the company. &lt;/p&gt;&lt;p&gt;&amp;nbsp;It is time that I continue this meme, and so I call upon the entities known as &lt;a href="http://www.allenkinsel.com/" target="_blank"&gt;Allen Kinsel&lt;/a&gt; and &lt;a href="http://littlekendra.com/" target="_blank"&gt;KenDrah&lt;/a&gt; to answer the question, How do YOU use SQL Server?&amp;nbsp; I instruct you to REVEAL ALL!&lt;br&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; Hey man, what the heck are you doing?&amp;nbsp; What is all this....omg.&amp;nbsp; This is how you repay me for being totally cool in the library of Yith?&amp;nbsp; NO! Don't hit publish! &lt;br&gt;&lt;/p&gt;&lt;img src="http://vsteamsystemcentral.com/cs21/aggbug.aspx?PostID=503" width="1" height="1"&gt;</description><category domain="http://vsteamsystemcentral.com/cs21/blogs/timbenninghoff/archive/tags/SQL+Server/default.aspx">SQL Server</category></item><item><title>Blank Page for SQL Server 2008 Reporting Services Report Manager</title><link>http://vsteamsystemcentral.com/cs21/blogs/timbenninghoff/archive/2009/11/10/blank-page-for-sql-server-2008-reporting-services-report-manager.aspx</link><pubDate>Wed, 11 Nov 2009 02:27:00 GMT</pubDate><guid isPermaLink="false">d291d4df-cf3d-4686-b1b1-8a0a96a3a0a7:501</guid><dc:creator>timbenninghoff</dc:creator><slash:comments>0</slash:comments><description>&lt;P&gt;Recently when I tried to access Reporting Services' Report Manager for a SQL Server 2008 Developer Edition SP1 instance on a Windows 2008 R2 Server, I got a completely blank screen.&amp;nbsp; It was not a &lt;A class="" href="http://social.msdn.microsoft.com/Forums/en/sqlreportingservices/thread/0072ba00-f1b7-4d9a-a346-9bd8e6d28605" target=_blank&gt;mostly blank screen&lt;/A&gt; still showing the header, nor was I getting the blank page after &lt;A class="" href="http://stackoverflow.com/questions/1373410/sql-2008-report-manager-not-accessible" target=_blank&gt;being prompted for my user credentials three times&lt;/A&gt;.&amp;nbsp; No, the page was loading immediately and was completely blank.&amp;nbsp; I checked the Windows logs, the SQL Server logs, and the Reporting Services log, and no errors were being logged.&lt;/P&gt;
&lt;P&gt;Fortunately I knew that the security department had recently made changes to that instance to enable Kerberos authentication in order to support Kerberos delegation for a web app that connected to our SQL Server and Reporting Services.&amp;nbsp; They'd dutifully documented all of the changes, and so since I didn't have any error logs to go on, I knew this was the only change that had happened recently and likely had to be the culprit.&lt;/P&gt;
&lt;P&gt;We used&amp;nbsp;the same&amp;nbsp;domain account to run both the SQL Server service and the Reporting Services in order to make our lives a tad bit easier, and I double checked that all of the SPNs were registered properly for the web server, SQL Server, and Reporting Services.&amp;nbsp; Figuring it had to be something related to the Reporting Services configuration, I noticed that they'd changed a setting in the RSReportServer.config file, located at C:\Program Files\Microsoft SQL Server\MSRS10.MSSQLSERVER\Reporting Services\ReportServer in a default install, and noticed they'd changed &amp;lt;AuthenticationTypes&amp;gt; to &amp;lt;RSWindowsKerberos/&amp;gt;.&amp;nbsp; I wanted to accept Kerberos or NTLM tokens, so BOL pointed me in the direction of using &lt;A class="" href="http://msdn.microsoft.com/en-us/library/ms157273.aspx" target=_blank&gt;&amp;lt;RSWindowsNegotiate/&amp;gt;&lt;/A&gt;.&amp;nbsp; But, despite BOL suggesting that this setting would be omitted if I were running in native mode and using a domain user for the service, I caved to my rebellious streak, removed &amp;lt;RSWindowsKerberos/&amp;gt;, replaced it with &amp;lt;RSWindowsNegotiate/&amp;gt; and hoped for the best.&amp;nbsp; It worked!&amp;nbsp; The web app continued to work via Kerberos authentication/delegation, and I was able to access my Report Manager again.&lt;/P&gt;
&lt;P&gt;I'm sure there's a moral to this story somewhere.&amp;nbsp; Mainly, though, I'm just very pleased that the security department and the consultant they had helping them were so diligent in documenting their changes.&amp;nbsp; I probably owe them a cookie or something.&lt;/P&gt;&lt;img src="http://vsteamsystemcentral.com/cs21/aggbug.aspx?PostID=501" width="1" height="1"&gt;</description><category domain="http://vsteamsystemcentral.com/cs21/blogs/timbenninghoff/archive/tags/SQL+Server+2008/default.aspx">SQL Server 2008</category></item><item><title>I'm a square.</title><link>http://vsteamsystemcentral.com/cs21/blogs/timbenninghoff/archive/2009/10/21/i-m-a-square.aspx</link><pubDate>Thu, 22 Oct 2009 01:07:00 GMT</pubDate><guid isPermaLink="false">d291d4df-cf3d-4686-b1b1-8a0a96a3a0a7:499</guid><dc:creator>timbenninghoff</dc:creator><slash:comments>1</slash:comments><description>&lt;p&gt;&lt;a href="http://summit2009.sqlpass.org/" target="_blank"&gt;PASS Summit 2009&lt;/a&gt; is rapidly approaching, and one of the features of the conference is the chance to meet new people who also work with SQL Server.&amp;nbsp; In order to help attendees meet new people, some folks have put together &lt;a href="http://codegumbo.com/index.php/2009/10/21/sql-pass-twitter-bingo-the-rules-so-far/" target="_blank"&gt;SQL PASS Twitter Bingo&lt;/a&gt;.&amp;nbsp; I've volunteered to be one of the squares on the randomly-generated bingo cards, and I'm really looking forward to meeting lots of attendees.&lt;/p&gt;&lt;p&gt;&amp;nbsp;Now, you've &lt;a href="http://www.sqlserverpedia.com/bingo/" target="_blank"&gt;read the proposed rules and seen the sample cards &lt;/a&gt;and you're probably wondering how, in the name of all six-legged beings, you are going to find a handful of people at a conference attended by a couple thousand people.&amp;nbsp; And to make matters worse, how are you going to find me, since my Twitter avatar isn't a &lt;a href="http://twitter.com/bugboi" target="_blank"&gt;picture of me&lt;/a&gt;?&lt;/p&gt;&lt;p&gt;Well, the goal of the game is to meet people, not be a detective, so I'm going to try to make myself more conspicuous by doing the following:&lt;/p&gt;&lt;p&gt;&amp;nbsp;1)&amp;nbsp; Publish my agenda on my Google calendar&amp;nbsp; - The sessions I plan on attending at the conference will be public, so feel free to look up my calendar to find out where I'm going to be.&lt;/p&gt;&lt;p&gt;2)&amp;nbsp; Twitter - I'll be tweeting my locations under my nom de plume, Bugboi.&amp;nbsp; Sessions may end up being full, or I may change my mind, and my calendar may not reflect where I actually am.&amp;nbsp; Twitter updates will point you in the right direction.&lt;br&gt;&lt;/p&gt;&lt;p&gt;3)&amp;nbsp; Bugs - Each day I'll be wearing a different insect-themed t-shirt, potentially paired with a blazer or jacket if it's cold.&amp;nbsp; Look for the bugs and that will probably be me, unless, of course, there is some other totally awesome person there who likes insects there at the conference.&lt;br&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;But, what if after all that effort you still can't find me?&amp;nbsp; Well, if you've found one person on your card, you might ask them if they know anyone else on the card, and they just might be able to point you in my direction.&amp;nbsp; Or the helpful folks staffing the Quest and PASS booths might be able to help you get started as well.&lt;/p&gt;&lt;p&gt;&amp;nbsp;Good luck, and I hope to see you at the Summit! &lt;br&gt;&lt;/p&gt;&lt;img src="http://vsteamsystemcentral.com/cs21/aggbug.aspx?PostID=499" width="1" height="1"&gt;</description><category domain="http://vsteamsystemcentral.com/cs21/blogs/timbenninghoff/archive/tags/PASS+Summit/default.aspx">PASS Summit</category></item><item><title>Design Anti-Pattern: Orphans by Design</title><link>http://vsteamsystemcentral.com/cs21/blogs/applied_database_development/archive/2009/08/19/design-anti-pattern-orphans-by-design.aspx</link><pubDate>Wed, 19 Aug 2009 22:00:00 GMT</pubDate><guid isPermaLink="false">d291d4df-cf3d-4686-b1b1-8a0a96a3a0a7:497</guid><dc:creator>andy</dc:creator><slash:comments>0</slash:comments><description>&lt;P&gt;&lt;STRONG&gt;Introduction&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;It's a surprisingly easy thing to do: create orphans by design in a database. In this post I present one such example.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Relationship First&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;First you need a a relationship between two tables. In this example, we'll start with a parent-child relationship.&lt;/P&gt;
&lt;P&gt;&lt;IMG src="http://vsteamsystemcentral.com/images/ext/ParentChild.jpg"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Looking at this diagram, you can infer a relationship between Parent and Child. The likely candidate key is ParentID. But - and this is a big butt (typo intentional)&amp;nbsp;- there is no relationship present in the database. If there was a relationship in the database, the diagram would appear as shown:&lt;/P&gt;
&lt;P&gt;&lt;IMG src="http://vsteamsystemcentral.com/images/ext/ParentChild1.jpg"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is called &lt;EM&gt;referential integrity&lt;/EM&gt; in database-speak. It's important because it defines and maintains this relationship between parent and child records. It prevents "orphans" - rows in the child table that do not have related rows in the parent. &lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;"So?"&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;"What's the big deal, Andy?" I'm glad you asked. &lt;/P&gt;
&lt;P&gt;Let's look at the downside of maintaining a relationship while developing against a couple tables with referential integrity applied:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;
&lt;DIV&gt;You have to write inserts a certain way. You cannot, for example, just poke a row into Child. It has to have a matching row in Parent. The value you insert into the Child.ParentID column must have a matching value in the Parent.ParentID column. If it doesn't already exist, you have to insert a row into Parent &lt;EM&gt;before&lt;/EM&gt; you do the insert into Child.&lt;/DIV&gt;&lt;/LI&gt;
&lt;LI&gt;
&lt;DIV&gt;You have to do deletes in a certain way. Similar to inserts, you cannot just delete a row willy-nilly from the Parent table. It may have related rows in the Child table, and those rows would be "orphaned" if you delete the parent. &lt;/DIV&gt;&lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;Now let's look at the upside of maintaining a relationship while developing against a couple tables with referential integrity applied:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;
&lt;DIV&gt;Your code will be built against a production-ready version of the database. Dropping keys may make your inserts work while developing, but it will cost you later. Truth is, you may develop bad code - and lots of it - before you realize the scope of the damage. &lt;/DIV&gt;&lt;/LI&gt;
&lt;LI&gt;
&lt;DIV&gt;Persistence is the art of state and data lends itself to certain designs. One key of good database design is: Identify the relationships and build the tables around them. It will be easier to design, build, maintain, load, and ultimately use.&lt;/DIV&gt;&lt;/LI&gt;
&lt;LI&gt;
&lt;DIV&gt;These aren't just helpful suggestions,&amp;nbsp;well-designed databases&amp;nbsp;perform and scale better; and well-designed databases&amp;nbsp;are designed with referential integrity.&lt;/DIV&gt;&lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;&lt;STRONG&gt;Constraints In Action&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;If you attempt to insert a row into the Child table without a related Parent table row, an error is raised. For example, if you attempt to execute this statement:&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:9pt;mso-no-proof:yes;"&gt;insert&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:9pt;mso-no-proof:yes;"&gt; &lt;SPAN style="COLOR:blue;"&gt;into&lt;/SPAN&gt; Child&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:gray;FONT-SIZE:9pt;mso-no-proof:yes;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:9pt;mso-no-proof:yes;"&gt;ParentID&lt;SPAN style="COLOR:gray;"&gt;,&lt;/SPAN&gt; ChildName&lt;SPAN style="COLOR:gray;"&gt;,&lt;/SPAN&gt; ChildValue&lt;SPAN style="COLOR:gray;"&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:blue;FONT-SIZE:9pt;mso-no-proof:yes;"&gt;Values&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:gray;FONT-SIZE:9pt;mso-no-proof:yes;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';FONT-SIZE:9pt;mso-no-proof:yes;"&gt;1&lt;SPAN style="COLOR:gray;"&gt;,&lt;/SPAN&gt; &lt;SPAN style="COLOR:red;"&gt;'A'&lt;/SPAN&gt;&lt;SPAN style="COLOR:gray;"&gt;,&lt;/SPAN&gt; 12&lt;SPAN style="COLOR:gray;"&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;an error similar to the following is raised:&lt;/P&gt;
&lt;P style="LINE-HEIGHT:normal;MARGIN:0in 0in 0pt;mso-layout-grid-align:none;" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY:'Courier New';COLOR:red;FONT-SIZE:9pt;mso-no-proof:yes;"&gt;Msg 547, Level 16, State 0, Line 2&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN:0in 0in 10pt;" class=MsoNormal&gt;&lt;SPAN style="LINE-HEIGHT:115%;FONT-FAMILY:'Courier New';COLOR:red;FONT-SIZE:9pt;mso-no-proof:yes;"&gt;The INSERT statement conflicted with the FOREIGN KEY constraint "FK_Child_Parent". The conflict occurred in database "TestDB", table "dbo.Parent", column 'ParentID'.&lt;/SPAN&gt;&lt;SPAN style="LINE-HEIGHT:115%;COLOR:red;FONT-SIZE:9pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;
&lt;P&gt;&lt;STRONG&gt;Defeating Constraints&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;It's possible to&amp;nbsp;defeat&amp;nbsp;constraints in several ways. I'm not going to&amp;nbsp;exhaust all the ways you can do this here. I'm just going to advise that you not do it... &lt;EM&gt;unless&lt;/EM&gt; you are absolutely certain you understand the implications of this action.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;The Anti-Pattern&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;The anti-pattern is shown in the first image above: there's a relationship, but it's managed elsewhere.&amp;nbsp;There are occassions when the right design involves managing the relationship in another location and not in the database. Those occassions are &lt;EM&gt;rare&lt;/EM&gt;. &lt;/P&gt;
&lt;P&gt;:{&amp;gt; Andy&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://vsteamsystemcentral.com/cs21/aggbug.aspx?PostID=497" width="1" height="1"&gt;</description><category domain="http://vsteamsystemcentral.com/cs21/blogs/applied_database_development/archive/tags/Constraints/default.aspx">Constraints</category><category domain="http://vsteamsystemcentral.com/cs21/blogs/applied_database_development/archive/tags/Orphans/default.aspx">Orphans</category><category domain="http://vsteamsystemcentral.com/cs21/blogs/applied_database_development/archive/tags/Design+Anti-Pattern/default.aspx">Design Anti-Pattern</category></item><item><title>Andy's Active August - Day 11</title><link>http://vsteamsystemcentral.com/cs21/blogs/andynontech/archive/2009/08/11/andy-s-active-august-day-11.aspx</link><pubDate>Tue, 11 Aug 2009 23:14:00 GMT</pubDate><guid isPermaLink="false">d291d4df-cf3d-4686-b1b1-8a0a96a3a0a7:495</guid><dc:creator>andy</dc:creator><slash:comments>0</slash:comments><description>&lt;P&gt;My &lt;A href="http://search.twitter.com/search?q=activeaugust" target=_blank&gt;#ActiveAugust&lt;/A&gt; goals have hit a snag. I'm injured. I've learned the hard way that I need to be careful, and I'll likely be sidelined for a few days healing. Durnit!&lt;/P&gt;
&lt;P&gt;AndysActiveAugust Metric:&amp;nbsp;10 for 11, or 0.91.&lt;/P&gt;
&lt;P&gt;:{&amp;lt;&lt;/P&gt;&lt;img src="http://vsteamsystemcentral.com/cs21/aggbug.aspx?PostID=495" width="1" height="1"&gt;</description><category domain="http://vsteamsystemcentral.com/cs21/blogs/andynontech/archive/tags/Exercise/default.aspx">Exercise</category><category domain="http://vsteamsystemcentral.com/cs21/blogs/andynontech/archive/tags/Active+August/default.aspx">Active August</category></item><item><title>Andy's Active August - Days 9 and 10</title><link>http://vsteamsystemcentral.com/cs21/blogs/andynontech/archive/2009/08/11/andy-s-active-august-days-9-and-10.aspx</link><pubDate>Tue, 11 Aug 2009 03:14:00 GMT</pubDate><guid isPermaLink="false">d291d4df-cf3d-4686-b1b1-8a0a96a3a0a7:494</guid><dc:creator>andy</dc:creator><slash:comments>0</slash:comments><description>&lt;P&gt;Sundays are the nemesis of my &lt;A href="http://search.twitter.com/search?q=activeaugust" target=_blank&gt;#ActiveAugust&lt;/A&gt; goals. It's a busy day with church and usually some sort of family activites thereafter. Last Sunday, 2 Aug, was the only day thus far I hadn't exercised. So this Sunday I was more than a little concerned.&lt;/P&gt;
&lt;P&gt;Christy wasn't feeling well, so we didn't get to church. Since Christy hadn't slept well the night before, a long summer's nap was in order. We kept Riley up a little longer than usual and talked Emma into laying down for her nap with Christy and Riley; and Stevie Ray and I made for the gym.&lt;/P&gt;
&lt;P&gt;For the third day in a row, I jogged a mile without stopping. Then I did 75 reps with 100 pounds. And then, when I stopped by the child care room, Stevie Ray was in the middle of a fierce game of UNO, so I returned to the gym and did 1/2 mile on the elliptical.&lt;/P&gt;
&lt;P&gt;Take that, Sunday!&lt;/P&gt;
&lt;P&gt;This morning I went to gym around 6:00 AM and jogged&amp;nbsp;my mile on the treadmill - again non-stop. Four in a row.&lt;/P&gt;
&lt;P&gt;Thursday and Friday are going to be tough this week, as I'm working from Richmond Thursday and presenting in Richmond Thursday night. We'll see how it goes...&lt;/P&gt;
&lt;P&gt;AndysActiveAugust Metric:&amp;nbsp;9 for 10, or 0.9.&lt;/P&gt;
&lt;P&gt;:{&amp;gt;&lt;/P&gt;&lt;img src="http://vsteamsystemcentral.com/cs21/aggbug.aspx?PostID=494" width="1" height="1"&gt;</description><category domain="http://vsteamsystemcentral.com/cs21/blogs/andynontech/archive/tags/Exercise/default.aspx">Exercise</category><category domain="http://vsteamsystemcentral.com/cs21/blogs/andynontech/archive/tags/Active+August/default.aspx">Active August</category></item><item><title>Andy's Active August - Days 7 and 8</title><link>http://vsteamsystemcentral.com/cs21/blogs/andynontech/archive/2009/08/08/andy-s-active-august-days-7-and-8.aspx</link><pubDate>Sat, 08 Aug 2009 23:21:00 GMT</pubDate><guid isPermaLink="false">d291d4df-cf3d-4686-b1b1-8a0a96a3a0a7:489</guid><dc:creator>andy</dc:creator><slash:comments>0</slash:comments><description>&lt;P&gt;It's been a couple days since I &lt;A href="http://vsteamsystemcentral.com/cs21/blogs/andynontech/archive/2009/08/06/andy-s-active-august-day-6.aspx" target=_blank&gt;last blogged&lt;/A&gt;. In between a couple long days at work, installing Windows 7 on the Red XPS laptop, and Riley's birthday cookout; I managed to exercise both days. My &lt;A href="http://search.twitter.com/search?q=activeaugust" target=_blank&gt;#ActiveAugust&lt;/A&gt; goals revolve around making exercise a habit. I want to work up to a challenging (for me) routine. My thinking is: If I can do this for a month (or most of a month) I can continue.&lt;/P&gt;
&lt;P&gt;To review, my goals are: Before &lt;A href="http://search.twitter.com/search?q=activeaugust" target=_blank&gt;#ActiveAugust&lt;/A&gt; ends I want to be able, in a single workout:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Jog&amp;nbsp;1 mile on the treadmill without taking a walk-break;&lt;/LI&gt;
&lt;LI&gt;Do 200 reps with 100 pounds.&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;Yesterday morning I hit half of my two-part goal. I ran a continuous mile on the treadmill without taking a walk-break. I was overjoyed, but I have to share I thought it was a fluke. And since running on the treadmill is easier for me than running ITRW (in the real world), my test was to try running to Worsham store and back. &lt;/P&gt;
&lt;P&gt;The&amp;nbsp;terrain from my driveway to&amp;nbsp;Worsham store is challenging. I start off going downhill for a good bit, then up a steep short hill. I go down a little and up a gentle slope to Route 15, then back the way I came. The end for me is a decent upslope for the last tenth of a mile or so. That's what I mean by challenging. &lt;/P&gt;
&lt;P&gt;I decided to jog it this afternoon, on a muggy dog day of August. And I made it! &lt;/P&gt;
&lt;P&gt;Now if you saw me "jogging" you'd laugh. I don't run, I shuffle. But I shuffled a mile without a break two days straight. &lt;A href="http://amileaday.blogspot.com/" target=_blank&gt;Steve Jones&lt;/A&gt;' record isn't in danger, but I feel like a million bucks (well, a sore million bucks). It's time to start working on getting those reps up, while maintaining a mile a day.&lt;/P&gt;
&lt;P&gt;AndysActiveAugust Metric:&amp;nbsp;7 for 8, or 0.875.&lt;/P&gt;
&lt;P&gt;:{&amp;gt; Andy&lt;/P&gt;&lt;img src="http://vsteamsystemcentral.com/cs21/aggbug.aspx?PostID=489" width="1" height="1"&gt;</description><category domain="http://vsteamsystemcentral.com/cs21/blogs/andynontech/archive/tags/Exercise/default.aspx">Exercise</category><category domain="http://vsteamsystemcentral.com/cs21/blogs/andynontech/archive/tags/Active+August/default.aspx">Active August</category></item><item><title>Andy's Active August - Day 6</title><link>http://vsteamsystemcentral.com/cs21/blogs/andynontech/archive/2009/08/06/andy-s-active-august-day-6.aspx</link><pubDate>Fri, 07 Aug 2009 00:52:00 GMT</pubDate><guid isPermaLink="false">d291d4df-cf3d-4686-b1b1-8a0a96a3a0a7:486</guid><dc:creator>andy</dc:creator><slash:comments>3</slash:comments><description>&lt;P&gt;Today was also close. After staying up too late last night&amp;nbsp;due to work&amp;nbsp;(and being old -&amp;nbsp;old people don't need sleep), my&amp;nbsp;&lt;A href="http://search.twitter.com/search?q=activeaugust" target=_blank&gt;#ActiveAugust&lt;/A&gt; aspirations were nearly dashed by sleeping in until after 6:00 AM &lt;EM&gt;again&lt;/EM&gt; for the second day in a row. In addition, it rained here most of last night - making it too wet to walk here near the house like yesterday. &lt;/P&gt;
&lt;P&gt;Technically, I could walk up the road to Worsham store just fine. It's when I meet a vehicle that it gets dicey. The Commonwealth of Virginia has decided to balance the budget by never mowing Abilene Road again. The weeds are about waist-high, even a foot off the road. I don't mind high weeds. I do mind high &lt;EM&gt;wet&lt;/EM&gt; weeds.&lt;/P&gt;
&lt;P&gt;"Pedestrians have the right of way" I hear you thinking. Folks, this is Farmville Virginia. We don't so much&amp;nbsp;rely the law of the land around here as much as we rely on the laws of physics. So when I say "vehicle," I mean "the two tons of rolling steel." In other words, I need to get off the road when a car approaches.&lt;/P&gt;
&lt;P&gt;As if that wasn't enough, I had enough work for three mornings&amp;nbsp;queued up. What to do, what to do? &lt;/P&gt;
&lt;P&gt;I grabbed my gear and made for the gym. Since I was running late, I decided jog as much as I could and skip the weights today. I wasn't running fast, but I managed to jog 0.6 miles continuously on the treadmill at 4.5 mph. I&amp;nbsp;ran probably another 0.2 miles near the end of the workout - sprinting 1/10th of a mile at 6 mph.&amp;nbsp;I knocked out 20 minutes of cardio, cooled down, and returned home to start the business day.&lt;/P&gt;
&lt;P&gt;AndysActiveAugust Metric:&amp;nbsp;5 for 6, or 0.833.&lt;/P&gt;
&lt;P&gt;:{&amp;gt;&lt;/P&gt;&lt;img src="http://vsteamsystemcentral.com/cs21/aggbug.aspx?PostID=486" width="1" height="1"&gt;</description><category domain="http://vsteamsystemcentral.com/cs21/blogs/andynontech/archive/tags/Exercise/default.aspx">Exercise</category><category domain="http://vsteamsystemcentral.com/cs21/blogs/andynontech/archive/tags/Active+August/default.aspx">Active August</category></item><item><title>Andy's Active August - Day 5</title><link>http://vsteamsystemcentral.com/cs21/blogs/andynontech/archive/2009/08/05/andy-s-active-august-day-5.aspx</link><pubDate>Thu, 06 Aug 2009 01:04:00 GMT</pubDate><guid isPermaLink="false">d291d4df-cf3d-4686-b1b1-8a0a96a3a0a7:483</guid><dc:creator>andy</dc:creator><slash:comments>0</slash:comments><description>&lt;P&gt;Today was close. After being inspired by &lt;A href="http://vsteamsystemcentral.com/cs21/blogs/timbenninghoff/" target=_blank&gt;Tim Benninghoff&lt;/A&gt;'s post about &lt;A href="http://vsteamsystemcentral.com/cs21/blogs/timbenninghoff/archive/2009/08/03/dynamic-sql-is-my-friend.aspx" target=_blank&gt;Dynamic SQL&lt;/A&gt; (and writing &lt;A href="http://vsteamsystemcentral.com/cs21/blogs/applied_database_development/archive/2009/08/05/dynamic-t-sql-today.aspx" target=_blank&gt;one&lt;/A&gt; of my own), I stayed up too late last night. The alarm is set for 5:30 AM to give me enough time to get up and stirring before heading to the gym at 6:00. I hit snooze a few times and didn't get up until about 6:30. &lt;/P&gt;
&lt;P&gt;That didn't leave enough time to make the gym and get back in time for the start of my work day. I thought about it for a bit, then threw on my gym shoes and headed outside. It was a balmy 68 or so out this morning&amp;nbsp;and as humid as Virginia gets in August. It didn't matter. I was on a mission.&lt;/P&gt;
&lt;P&gt;I walked from the old farmhouse up to Worsham store - about 1/2 mile. On the way back I detoured down a farm road for an addition 0.2 miles or so. Then I went past our driveway on the return trip for another 0.3 miles or so. I guestimate I walked 1.5 miles.&lt;/P&gt;
&lt;P&gt;AndysActiveAugust Metric:&amp;nbsp;4 for 5, or 0.8.&lt;/P&gt;
&lt;P&gt;:{&amp;gt;&lt;/P&gt;&lt;img src="http://vsteamsystemcentral.com/cs21/aggbug.aspx?PostID=483" width="1" height="1"&gt;</description><category domain="http://vsteamsystemcentral.com/cs21/blogs/andynontech/archive/tags/Exercise/default.aspx">Exercise</category><category domain="http://vsteamsystemcentral.com/cs21/blogs/andynontech/archive/tags/Active+August/default.aspx">Active August</category></item><item><title>Dynamic T-SQL Today</title><link>http://vsteamsystemcentral.com/cs21/blogs/applied_database_development/archive/2009/08/05/dynamic-t-sql-today.aspx</link><pubDate>Wed, 05 Aug 2009 03:09:00 GMT</pubDate><guid isPermaLink="false">d291d4df-cf3d-4686-b1b1-8a0a96a3a0a7:480</guid><dc:creator>andy</dc:creator><slash:comments>1</slash:comments><description>&lt;P&gt;I was just reading Tim Benninghoff's latest post: &lt;A href="http://vsteamsystemcentral.com/cs21/blogs/timbenninghoff/archive/2009/08/03/dynamic-sql-is-my-friend.aspx" target=_blank&gt;Dynamic SQL is my administration buddy&lt;/A&gt;&amp;nbsp;and it got me thinking (Tim's posts often get me thinking) about how much I use dynamic SQL each day.&lt;BR&gt;&lt;BR&gt;Just today I needed to create a test query to count the rows in every table in a database, then create another query to truncate each table in the same database. To prove the truncation had occurred, I would need to execute the test script before and after the truncate script. There were several tables in the database.&lt;BR&gt;&lt;BR&gt;So I built the following T-SQL script to build the counts query:&lt;BR&gt;&lt;BR&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;select&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;&lt;FONT color=#ff0000 size=2&gt;'select'&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&lt;FONT color=#808080 size=2&gt;+&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;char&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&lt;FONT color=#808080 size=2&gt;(&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;13&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&lt;FONT color=#808080 size=2&gt;)&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&lt;FONT color=#808080 size=2&gt;+&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;char&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&lt;FONT color=#808080 size=2&gt;(&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;10&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&lt;FONT color=#808080 size=2&gt;)&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;union all&lt;BR&gt;select&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;&lt;FONT color=#ff0000 size=2&gt;'(select count(*) from '&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&lt;FONT color=#808080 size=2&gt;+&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff00ff size=2&gt;&lt;FONT color=#ff00ff size=2&gt;schema_name&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&lt;FONT color=#808080 size=2&gt;(&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#ff00ff size=2&gt;&lt;FONT color=#ff00ff size=2&gt;schema_id&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&lt;FONT color=#808080 size=2&gt;)&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&lt;FONT color=#808080 size=2&gt;+&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;&lt;FONT color=#ff0000 size=2&gt;'.'&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&lt;FONT color=#808080 size=2&gt;+&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;name&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&lt;FONT color=#808080 size=2&gt;+&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;&lt;FONT color=#ff0000 size=2&gt;') as '&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&lt;FONT color=#808080 size=2&gt;+&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;name&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&lt;FONT color=#808080 size=2&gt;+&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;&lt;FONT color=#ff0000 size=2&gt;'_RecCount,'&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;from&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;&lt;FONT color=#008000 size=2&gt;sys.tables&lt;BR&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;&lt;FONT color=#008000 size=2&gt;&lt;FONT color=#000000&gt;This output of this query resembled the following:&lt;BR&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;select&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&lt;FONT color=#808080 size=2&gt;(&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;select&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff00ff size=2&gt;&lt;FONT color=#ff00ff size=2&gt;count&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&lt;FONT color=#808080 size=2&gt;(*)&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;from&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; dbo&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&lt;FONT color=#808080 size=2&gt;.&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;incr&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&lt;FONT color=#808080 size=2&gt;)&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;as&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; incr_RecCount&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&lt;FONT color=#808080 size=2&gt;,&lt;BR&gt;(&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;select&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff00ff size=2&gt;&lt;FONT color=#ff00ff size=2&gt;count&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&lt;FONT color=#808080 size=2&gt;(*)&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;from&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; dbo&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&lt;FONT color=#808080 size=2&gt;.&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;PKTest&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&lt;FONT color=#808080 size=2&gt;)&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;as &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;PKTest_RecCount&lt;BR&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;&lt;FONT color=#008000 size=2&gt;&lt;FONT color=#000000&gt;(Except there were lots more tables) This was cool - it created a single row containing counts of all the tables in the database.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;The truncate script read:&lt;BR&gt;&lt;BR&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;select&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;&lt;FONT color=#ff0000 size=2&gt;'truncate table '&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&lt;FONT color=#808080 size=2&gt;+&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff00ff size=2&gt;&lt;FONT color=#ff00ff size=2&gt;schema_name&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&lt;FONT color=#808080 size=2&gt;(&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#ff00ff size=2&gt;&lt;FONT color=#ff00ff size=2&gt;schema_id&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&lt;FONT color=#808080 size=2&gt;)&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&lt;FONT color=#808080 size=2&gt;+&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;&lt;FONT color=#ff0000 size=2&gt;'.'&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&lt;FONT color=#808080 size=2&gt;+&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;name&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;from&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;&lt;FONT color=#008000 size=2&gt;sys.tables&lt;BR&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;And the generated output reads:&lt;BR&gt;&lt;BR&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;truncate&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;table&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; dbo&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&lt;FONT color=#808080 size=2&gt;.&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;incr&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;truncate&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;table&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; dbo&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&lt;FONT color=#808080 size=2&gt;.&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;PKTest&lt;BR&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;&lt;FONT color=#008000 size=2&gt;&lt;FONT color=#000000&gt;Pretty cool. It took way less time to write&amp;nbsp;the T-SQL generator code than it would have taken to type this out.&lt;BR&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;I ran the counts script,&amp;nbsp;saved the results in Excel, executed the truncates, re-ran the counts script, and pasted those results into Excel below the previous results. A quick visual confirmed the truncates worked, and I have a handy artifact to attach (along with the generated scripts) to the ticket.&lt;BR&gt;&lt;BR&gt;&lt;FONT color=#008000 size=2&gt;&lt;FONT color=#008000 size=2&gt;&lt;FONT color=#000000&gt;:{&amp;gt; Andy&lt;/FONT&gt;&lt;/P&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;img src="http://vsteamsystemcentral.com/cs21/aggbug.aspx?PostID=480" width="1" height="1"&gt;</description><category domain="http://vsteamsystemcentral.com/cs21/blogs/applied_database_development/archive/tags/Dynamic+SQL/default.aspx">Dynamic SQL</category></item><item><title>Andy's Active August - Day 4</title><link>http://vsteamsystemcentral.com/cs21/blogs/andynontech/archive/2009/08/05/andy-s-active-august-day-4.aspx</link><pubDate>Wed, 05 Aug 2009 02:13:00 GMT</pubDate><guid isPermaLink="false">d291d4df-cf3d-4686-b1b1-8a0a96a3a0a7:479</guid><dc:creator>andy</dc:creator><slash:comments>0</slash:comments><description>&lt;P&gt;I did something today I haven't done in &lt;EM&gt;weeks&lt;/EM&gt; - I made it to the gym for the second day in a row, Maybe it's all psychosomatic (or just plain psycho), but I felt better today.&lt;/P&gt;
&lt;P&gt;I did 1.5 miles on the treadmill - enough to get a minimum good cardio workout for 20 minutes - and then started on the weights. In keeping with not hurting myself and ramping up slowly, I only did 20 reps with 100 pounds. &lt;/P&gt;
&lt;P&gt;I'm a little late setting goals but here they are. Before &lt;A href="http://search.twitter.com/search?q=activeaugust" target=_blank&gt;#ActiveAugust&lt;/A&gt; ends I want to be able, in a single workout:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Jog&amp;nbsp;1 mile on the treadmill without taking a walk-break;&lt;/LI&gt;
&lt;LI&gt;Do 200 reps with 100 pounds.&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;I realize this isn't that much for most folks. It's huge for me.&lt;/P&gt;
&lt;P&gt;AndysActiveAugust Metric:&amp;nbsp;3 for 4, or .75.&lt;/P&gt;
&lt;P&gt;:{&amp;gt; Andy&lt;/P&gt;&lt;img src="http://vsteamsystemcentral.com/cs21/aggbug.aspx?PostID=479" width="1" height="1"&gt;</description><category domain="http://vsteamsystemcentral.com/cs21/blogs/andynontech/archive/tags/Exercise/default.aspx">Exercise</category><category domain="http://vsteamsystemcentral.com/cs21/blogs/andynontech/archive/tags/Active+August/default.aspx">Active August</category></item><item><title>Dynamic SQL is my administration buddy.</title><link>http://vsteamsystemcentral.com/cs21/blogs/timbenninghoff/archive/2009/08/03/dynamic-sql-is-my-friend.aspx</link><pubDate>Tue, 04 Aug 2009 02:28:00 GMT</pubDate><guid isPermaLink="false">d291d4df-cf3d-4686-b1b1-8a0a96a3a0a7:478</guid><dc:creator>timbenninghoff</dc:creator><slash:comments>2</slash:comments><description>&lt;p&gt;In the age of SQL injection attacks, the dangers of dynamic SQL are pretty well documented.&amp;nbsp; But, as with most things, there's a time and a place for them.&amp;nbsp; I recently indulged in a trip down memory lane, reviewing the scripts in my 'toolbox' that I use for administration, and I was reminded of how much I use dynamic SQL for my day-to-day administrative tasks.&amp;nbsp; For many, this blog post isn't going to break any new ground.&amp;nbsp; Consider it an homage to my favorite aspect of dynamic sql in t-sql; the ability to do administrative tasks en masse.&lt;br&gt;&lt;/p&gt;&lt;p&gt;For example, at work we use SQL Agent extensively for plenty of administrative tasks.&amp;nbsp; In those rare instance when one of those jobs should break, we like to know what happened in as much detail as possible.&amp;nbsp; So, we use SQL Agent's step history to log that information to a text file and email the log file to us.&amp;nbsp; But, when I'm building a large job, going into the Advanced page of the Job Step properties through SSMS and defining the output file for each step can get rather tedious.&lt;/p&gt;&lt;p&gt;&amp;nbsp;Enter dynamic SQL.&amp;nbsp; After I've built the job, I open up a Query window, and build a quick script like this:&lt;/p&gt;&lt;p&gt;DECLARE @sql varchar(max);&lt;br&gt;&lt;br&gt;SET @sql = '';&lt;br&gt;&lt;br&gt;SELECT @sql = @sql + 'EXEC msdb.dbo.sp_update_jobstep @job_id='''+CAST(job.job_id AS varchar(max))+''',@step_id='+CAST(step.step_id as varchar(10))+',@output_file_name=''G:\JobLogs\&amp;lt;jobname&amp;gt;.log'',@flags=6'&lt;br&gt;FROM msdb.dbo.sysjobs AS job&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; JOIN msdb.dbo.sysjobsteps AS step&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ON job.job_id=step.job_id&lt;br&gt;WHERE job.name = '&amp;lt;jobname&amp;gt;'&lt;br&gt;AND step.step_id &amp;gt; 1;&lt;br&gt;&lt;br&gt;&amp;nbsp;EXEC(@sql);&lt;/p&gt;&lt;p&gt;&amp;nbsp;As you can see, using the information from the SQL Agent system tables stored in msdb, I build a variable to string together executions of sp_update_jobstep in order to update all of the steps in my job, except the first one, to use the same log file, to append the step's history to that log file, and to also include the step information into SQL Agent's history, and then I execute that statement, which modifies all of the steps at the same time.&lt;/p&gt;&lt;p&gt;In jobs that have 10s, if not a 100 steps, I've saved myself quite a bit of time from having to go through the GUI.&lt;/p&gt;&lt;p&gt;Now,this certainly isn't the only way I could have done this task.&amp;nbsp; I could also have scripted out the job through SSMS, done a Find/Replace to change the values for @flags and @output_file_name.&amp;nbsp; but, since I'm weird and I also want my first step to NOT append to the log file because I want the file to be 'new' every time the job executes, I'd have to then go back and search through the code to find the first step and change the @flags value.&amp;nbsp; Then, in SQL Server 2005, I'd have to drop the job and run the script to recreate.&amp;nbsp; But, no, I think I like dynamic SQL just fine. &lt;br&gt;&lt;/p&gt;&lt;img src="http://vsteamsystemcentral.com/cs21/aggbug.aspx?PostID=478" width="1" height="1"&gt;</description><category domain="http://vsteamsystemcentral.com/cs21/blogs/timbenninghoff/archive/tags/T-SQL/default.aspx">T-SQL</category></item><item><title>Andy's Active August - Days 2 and 3</title><link>http://vsteamsystemcentral.com/cs21/blogs/andynontech/archive/2009/08/03/andy-s-active-august-days-2-and-3.aspx</link><pubDate>Mon, 03 Aug 2009 21:30:00 GMT</pubDate><guid isPermaLink="false">d291d4df-cf3d-4686-b1b1-8a0a96a3a0a7:477</guid><dc:creator>andy</dc:creator><slash:comments>0</slash:comments><description>&lt;P&gt;As suspected, Sunday proved to be a challenge to my plans for an &lt;A href="http://search.twitter.com/search?q=activeaugust" target=_blank&gt;#ActiveAugust&lt;/A&gt;. But this morning - Monday, 3 Aug 2009, which also happens to be Riley's 2nd birthday (Happy Birthday Boof!) - I dragged my tired self out of bed earlier than I had been and hit the gym. I did 25 minutes total on the treadmill - barely qualifying as a useful workout. &lt;/P&gt;
&lt;P&gt;I didn't touch the weights - maybe tomorrow. I was telling my marketing and project manager friends (ok, I have one project manager who hasn't blocked me and a former marketing person as a friend) that I was lifting 10,000 pounds! That's 10 sets of 10 reps with 100 pounds. Oddly, they both got the math. Right away.&lt;/P&gt;
&lt;P&gt;It had a been a while since I worked out. I have this theory that entropy accelerates with age. Exhibit A: I don't think I'd been to the gym since before my last birthday. &lt;/P&gt;
&lt;P&gt;I'm sore. But I think that's part of it - I'm sore with a bunch of other &lt;A href="http://search.twitter.com/search?q=activeaugust" target=_blank&gt;#ActiveAugust&lt;/A&gt; tweeps. We're&amp;nbsp;sore together - isn't that cool? Tomorrow I hope to make it two days in a row - for the first time in more than a month. Economic analysis:&amp;nbsp;July's payment to the YMCA was profitable for them and expensive for me. Durnit!&lt;/P&gt;
&lt;P&gt;On a side note - check out @&lt;A href="http://twitter.com/sqlagentman" target=_blank&gt;sqlagentman&lt;/A&gt;'s &lt;A href="http://www.ford-it.com/sqlagentman/?p=340" target=_blank&gt;funny blog post&lt;/A&gt;&amp;nbsp;about his (in)ActiveAugust!&lt;/P&gt;
&lt;P&gt;AndysActiveAugust Metric: 2 for 3, or .666.&lt;/P&gt;
&lt;P&gt;:{&amp;gt; Andy&lt;/P&gt;&lt;img src="http://vsteamsystemcentral.com/cs21/aggbug.aspx?PostID=477" width="1" height="1"&gt;</description><category domain="http://vsteamsystemcentral.com/cs21/blogs/andynontech/archive/tags/Exercise/default.aspx">Exercise</category><category domain="http://vsteamsystemcentral.com/cs21/blogs/andynontech/archive/tags/Active+August/default.aspx">Active August</category></item><item><title>Andy's Active August - Day 1</title><link>http://vsteamsystemcentral.com/cs21/blogs/andynontech/archive/2009/08/02/andy-s-active-august-day-1.aspx</link><pubDate>Sun, 02 Aug 2009 03:59:00 GMT</pubDate><guid isPermaLink="false">d291d4df-cf3d-4686-b1b1-8a0a96a3a0a7:474</guid><dc:creator>andy</dc:creator><slash:comments>1</slash:comments><description>&lt;P&gt;1 Aug 2009: Today's cardio was mowing. &lt;/P&gt;
&lt;P&gt;About half of the three acres we (and the mortgage company) own is covered with grass - the kind that insists on growing. It's been a couple weeks since I gave it all a good mow. My neighbors were shaming me with their mowed lawns, and I'm a sucker for peer pressure (as I mentioned in my &lt;A href="http://vsteamsystemcentral.com/cs21/blogs/andynontech/archive/2009/08/02/andy-s-active-august-intro.aspx" target=_blank&gt;previous post&lt;/A&gt;).&lt;/P&gt;
&lt;P&gt;We own a riding mower. &lt;A href="http://christycooks.com/" target=_blank&gt;Christy&lt;/A&gt; found it three years ago when we bought the house. It was used and&amp;nbsp;needed a little love. But it was only $275 for a 42" tri-blade deck, 18HP Briggs and Stratton engine. And it was running. Most of our yard lends itself to riding mower mowing. The hill out front does not.&lt;/P&gt;
&lt;P&gt;For the hill, I use a push mower. It's one that bags the grass, so it actually gets heavier as I go. Mowing the hill takes about 30 minutes.&amp;nbsp;It's a decent cardio workout - as good or better as I get at the gym. The 90 DegF heat and humidity added to the fun. &lt;/P&gt;
&lt;P&gt;So Day One is in the books. Tomorrow will be tricky. I don't usually go to the gym on Sundays, and I've already mowed the grass. I'll need to be creative.&lt;/P&gt;
&lt;P&gt;:{&amp;gt; Andy&lt;/P&gt;&lt;img src="http://vsteamsystemcentral.com/cs21/aggbug.aspx?PostID=474" width="1" height="1"&gt;</description><category domain="http://vsteamsystemcentral.com/cs21/blogs/andynontech/archive/tags/Exercise/default.aspx">Exercise</category><category domain="http://vsteamsystemcentral.com/cs21/blogs/andynontech/archive/tags/Active+August/default.aspx">Active August</category></item><item><title>Andy's Active August - Intro</title><link>http://vsteamsystemcentral.com/cs21/blogs/andynontech/archive/2009/08/02/andy-s-active-august-intro.aspx</link><pubDate>Sun, 02 Aug 2009 03:15:00 GMT</pubDate><guid isPermaLink="false">d291d4df-cf3d-4686-b1b1-8a0a96a3a0a7:473</guid><dc:creator>andy</dc:creator><slash:comments>1</slash:comments><description>&lt;P&gt;I'm going to participate in &lt;A href="http://search.twitter.com/search?q=ActiveAugust" target=_blank&gt;#ActiveAugust&lt;/A&gt; for a couple reasons:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;A bunch of my Twitter friends are doing it.&lt;/LI&gt;
&lt;LI&gt;I really need to be more active.&lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;My plans are to go cardio each day. For me, doing something that gets my heart rate into workout range every day for 31 days would be astounding - and very good for me. Most studies say it takes 21 days to form a habit. This has the engineer's allure of &lt;EM&gt;10 redundant days&lt;/EM&gt;! &lt;/P&gt;
&lt;P&gt;I know the value of inspiration in physical activity. I was never good at sports in school -&amp;nbsp;almost always picked last for anything that required speed or physical coordination (not looking for sympathy, just sharing). As I told my oldest daughter earlier tonight: When she was her daughter's (my granddaughter's) age, I was in Basic Training at Fort McClellan, AL. (Note to those considering enlisting: Go &lt;EM&gt;NORTH &lt;/EM&gt;if you're going to do Basic Training in the summer months!) I remember thinking "I'll never make this. I can't run." But I could run. The first morning we got up early (well, "early" if you didn't grow up on a farm) and we ran around a block - probably not more than 1/10th of a mile. We ran in formation. We were in step and maintained a distance from each other. We chanted while we ran. There was a palpable sense of camaraderie. One day near the end of boot camp, we ran about 6 miles. In August. In Alabama. (See previous note...)&lt;/P&gt;
&lt;P&gt;I've been inspired by the people in our SQL Server&amp;nbsp;community: &lt;A href="http://ford-it.com/" target=_blank&gt;Tim Ford&lt;/A&gt;, &lt;A href="http://twitter.com/donalddotfarmer" target=_blank&gt;Donald Farmer&lt;/A&gt;, &lt;A href="http://thomaslarock.com/" target=_blank&gt;Thomas LaRock&lt;/A&gt;,&lt;A href="http://twitter.com/tjaybelt" target=_blank&gt; T. Jay Belt&lt;/A&gt;, &lt;A href="http://twitter.com/paulrandal" target=_blank&gt;Paul Randal&lt;/A&gt;, &lt;A href="http://twitter.com/chuckboycejr" target=_blank&gt;Chuck Boyce&lt;/A&gt;,&amp;nbsp;&lt;A href="http://twitter.com/kimberlyltripp" target=_blank&gt;Kimberly Tripp&lt;/A&gt;, &lt;A href="http://twitter.com/mattmasson" target=_blank&gt;Matt Masson&lt;/A&gt;, &lt;A href="http://twitter.com/mrdenny" target=_blank&gt;Denny Cherry&lt;/A&gt;, &lt;A href="http://twitter.com/SQLGal" target=_blank&gt;Lara Rubbelke&lt;/A&gt;, &lt;A href="http://twitter.com/john_welch" target=_blank&gt;John Welch&lt;/A&gt;, &lt;A href="http://twitter.com/pswaters" target=_blank&gt;Paul Waters&lt;/A&gt;, &lt;A href="http://twitter.com/jessicammoss" target=_blank&gt;Jessica Moss&lt;/A&gt;, &lt;A href="http://twitter.com/drsql" target=_blank&gt;Louis Davidson&lt;/A&gt;, &lt;A href="http://twitter.com/kbriankelley" target=_blank&gt;Brian Kelley&lt;/A&gt;, &lt;A href="http://brentozar.com/" target=_blank&gt;Brent Ozar&lt;/A&gt;, &lt;A href="http://twitter.com/mike_walsh" target=_blank&gt;Mike Walsh&lt;/A&gt;, &lt;A href="http://farmchronicles.wordpress.com/" target=_blank&gt;Joe Webb&lt;/A&gt;, &lt;A href="http://scarydba.wordpress.com/" target=_blank&gt;Grant Fritchey&lt;/A&gt;, &lt;A href="http://twitter.com/SQLChicken" target=_blank&gt;Jorge Segarra&lt;/A&gt;, everyone in the Richmond Developer Comunity, and so many others (apologies, I know I left people out!). They share their&amp;nbsp;expertise on Twitter, but they share so much more - their lives. I'm so blessed to be part of this community, and humbled by their acceptance. I no longer feel like the last kid chosen.&lt;/P&gt;
&lt;P&gt;It's time. Maybe past time. I've been inspired long enough - it's time to act on the inspiration. So I'm in. &lt;/P&gt;
&lt;P&gt;:{&amp;gt; Andy&lt;/P&gt;
&lt;P&gt;PS - Steve Jones encouraged me to have a separate blog for personal stuff. Thanks Steve!&lt;/P&gt;&lt;img src="http://vsteamsystemcentral.com/cs21/aggbug.aspx?PostID=473" width="1" height="1"&gt;</description><category domain="http://vsteamsystemcentral.com/cs21/blogs/andynontech/archive/tags/Exercise/default.aspx">Exercise</category><category domain="http://vsteamsystemcentral.com/cs21/blogs/andynontech/archive/tags/Active+August/default.aspx">Active August</category></item><item><title>WeatherData: Create the Database</title><link>http://vsteamsystemcentral.com/cs21/blogs/applied_database_development/archive/2009/07/30/weatherdata-create-the-database.aspx</link><pubDate>Thu, 30 Jul 2009 02:01:00 GMT</pubDate><guid isPermaLink="false">d291d4df-cf3d-4686-b1b1-8a0a96a3a0a7:394</guid><dc:creator>andy</dc:creator><slash:comments>0</slash:comments><description>&lt;P&gt;&lt;STRONG&gt;Introduction&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;This is the first post in a series called WeatherData.&amp;nbsp;In this series I am going to demonstrate principles of test-driven database development (TD3).&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Build the Solution&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Did you know you can use SSMS to build a database project? You can. I'm going to use SSMS 2005.&amp;nbsp;To&amp;nbsp;follow along, open SSMS and click File &amp;gt; New &amp;gt; Project:&lt;/P&gt;
&lt;P&gt;&lt;IMG src="http://vsteamsystemcentral.com/images/ext/WeatherData_0_0.jpg"&gt;&lt;/P&gt;
&lt;P&gt;When the&amp;nbsp;New Project form displays, select the SQL Server Scripts template in the uppoer pane:&lt;/P&gt;
&lt;P&gt;&lt;IMG src="http://vsteamsystemcentral.com/images/ext/WeatherData_0_1.jpg"&gt;&lt;/P&gt;
&lt;P&gt;In the lower portion of the New Project form, name the&amp;nbsp;project WeatherData:&lt;/P&gt;
&lt;P&gt;&lt;IMG src="http://vsteamsystemcentral.com/images/ext/WeatherData_0_2.jpg"&gt;&lt;/P&gt;
&lt;P&gt;When you click Ok, the database project is created. To view the Solution Explorer, click View &amp;gt; Solution Explorer:&lt;/P&gt;
&lt;P&gt;&lt;IMG src="http://vsteamsystemcentral.com/images/ext/WeatherData_0_3.jpg"&gt;&lt;/P&gt;
&lt;P&gt;Solution Explorer, for our empty WeatherData solution, looks like this:&lt;/P&gt;
&lt;P&gt;&lt;IMG src="http://vsteamsystemcentral.com/images/ext/WeatherData_0_4.jpg"&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Write the Test - Part 1: Create the Query File&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Test-First Development is a popular variantof Test-Driven Development. You write and execute a test &lt;EM&gt;first&lt;/EM&gt;, execute it, and it fails. This works very well for me, as most of my initial development efforts fail anyway! ;)&lt;/P&gt;
&lt;P&gt;The first thing we'll need to do is create the database, so our first test will check for the database.&lt;/P&gt;
&lt;P&gt;To create the test, right-click the Queries folder and click New Query:&lt;/P&gt;
&lt;P&gt;&lt;IMG src="http://vsteamsystemcentral.com/images/ext/WeatherData_0_5.jpg"&gt;&lt;/P&gt;
&lt;P&gt;When you create the first query, you'll be prompted to connect to a database:&lt;/P&gt;
&lt;P&gt;&lt;IMG src="http://vsteamsystemcentral.com/images/ext/WeatherData_0_6.jpg"&gt;&lt;/P&gt;
&lt;P&gt;Once you connect, the connection is added to the Connections folder:&lt;/P&gt;
&lt;P&gt;&lt;IMG src="http://vsteamsystemcentral.com/images/ext/WeatherData_0_7.jpg"&gt;&lt;/P&gt;
&lt;P&gt;Before we actually write the test, let's give SQLQuery1.sql a more descriptive name. I'd really like to be able to create a subfolder here and name it Tests. Alas, I cannot. So I am constrained to separate types of query files by their name. In this case, I choose to identify&amp;nbsp;test queries by prefixing them with the text: "Test_". &lt;/P&gt;
&lt;P&gt;Right-click&amp;nbsp;SQLQuery1.sql and click Rename:&lt;/P&gt;
&lt;P&gt;&lt;IMG src="http://vsteamsystemcentral.com/images/ext/WeatherData_0_8.jpg"&gt;&lt;/P&gt;
&lt;P&gt;I chose to name my test "Test_CreateWeatherData.db.sql":&lt;/P&gt;
&lt;P&gt;&lt;IMG src="http://vsteamsystemcentral.com/images/ext/WeatherData_0_9.jpg"&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;I like the file naming convention&amp;nbsp;employed by Visual Studio Team System&amp;nbsp;Database Edition. It's [&lt;EM&gt;ScriptName&lt;/EM&gt;].[&lt;EM&gt;ObjectType&lt;/EM&gt;].sql; so I use it here.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Write the Test - Part 2: Write Some Test T-Sql&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;It's important to stop here and talk some about test theory. &lt;/P&gt;
&lt;P&gt;Let's talk first about test results. How will you know the test succeeded or failed? Do you want to return results that can be stored for posterity? If so, how? We'll start with test results that are only available at test time. We are&amp;nbsp;finally ready to actually write some T-Sql! &lt;/P&gt;
&lt;P&gt;The first test will be simple:&lt;/P&gt;&lt;FONT face="Courier New"&gt;&lt;FONT color=#0000ff&gt;
&lt;P&gt;Use&lt;/FONT&gt; WeatherData&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;When this test is executed in SSMS, the result is an error message:&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" color=red&gt;Msg 911, Level 16, State 1, Line 1&lt;BR&gt;Could not locate entry in sysdatabases for database 'WeatherData'. No entry found with that name. Make sure that the name is entered correctly.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;The test failed, which is what we wanted, so Success! (Are you confused yet?) &lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Error Trapping&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Another way to approach this test is to trap the error in a way that doesn't cause an error condition to occur. I can hear you asking: "Andy why is it important to not cause an error condition?" I'm glad you asked! Exceptions in the T-Sql will stop the T-Sql execution. The technical term for that is "bad." If the test code doesn't complete, our test results will be inconclusive.&lt;/P&gt;
&lt;P&gt;Inconclusive&lt;EM&gt; is a valid test result. It's pretty obvious tests can either succeed or fail. Based on this, most assume there are two possible outcomes to a test: success or failure. There are actually four states to two-state logic: &lt;/EM&gt;&lt;/P&gt;&lt;EM&gt;
&lt;UL&gt;
&lt;LI&gt;
&lt;DIV&gt;On (Success in testing)&lt;/DIV&gt;&lt;/LI&gt;
&lt;LI&gt;
&lt;DIV&gt;Off (Failure)&lt;/DIV&gt;&lt;/LI&gt;
&lt;LI&gt;
&lt;DIV&gt;Don't Know (Inconclusive)&lt;/DIV&gt;&lt;/LI&gt;
&lt;LI&gt;
&lt;DIV&gt;Don't Care (Ignored)&lt;/DIV&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/EM&gt;
&lt;P&gt;In SQL Server 2005 and beyond,&amp;nbsp;T-Sql provides just the trick for this: Try/Catch.&amp;nbsp;Also included are a couple functions to&amp;nbsp;check for the expected error: Error_Number() and Error_Message(). Let's test this by executing the following T-Sql:&lt;/P&gt;&lt;FONT face="Courier New"&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;
&lt;P&gt;Begin&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;Try&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;Select&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color=#ff00ff&gt;&lt;FONT color=#ff00ff&gt;Convert&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#808080&gt;&lt;FONT color=#808080&gt;(&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;int&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#808080&gt;&lt;FONT color=#808080&gt;,&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color=#ff0000&gt;&lt;FONT color=#ff0000&gt;'One'&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#808080&gt;&lt;FONT color=#808080&gt;)&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;End&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;Try&lt;BR&gt;Begin&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;Catch&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;Print&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color=#ff00ff&gt;&lt;FONT color=#ff00ff&gt;Error_Number&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#808080&gt;&lt;FONT color=#808080&gt;()&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;Print&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color=#ff00ff&gt;&lt;FONT color=#ff00ff&gt;Error_Message&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#808080&gt;&lt;FONT color=#808080&gt;()&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;End&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;Catch&lt;/P&gt;&lt;/FONT&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;/FONT&gt;The results are:&lt;/P&gt;&lt;FONT face="Courier New"&gt;
&lt;P&gt;-----------&lt;BR&gt;(0 row(s) affected)&lt;BR&gt;245&lt;BR&gt;Conversion failed when converting the varchar value 'One' to data type int. &lt;/P&gt;&lt;/FONT&gt;
&lt;P&gt;The cool part is the query completed successfully - &lt;EM&gt;without&lt;/EM&gt; error:&lt;/P&gt;
&lt;P&gt;&lt;IMG src="http://vsteamsystemcentral.com/images/ext/WeatherData_0_10.jpg"&gt;&lt;/P&gt;
&lt;P&gt;Let's apply this to our database test query:&lt;FONT face="Courier New"&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;&lt;/P&gt;
&lt;P&gt;Begin&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;Try&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;Use&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#000000&gt; WeatherData&lt;/FONT&gt;&lt;FONT color=#808080&gt;&lt;FONT color=#808080&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;End&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;Try&lt;BR&gt;Begin&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;Catch&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;Print&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color=#ff00ff&gt;&lt;FONT color=#ff00ff&gt;Error_Number&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#808080&gt;&lt;FONT color=#808080&gt;()&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;Print&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color=#ff00ff&gt;&lt;FONT color=#ff00ff&gt;Error_Message&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#808080&gt;&lt;FONT color=#808080&gt;()&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;End&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;Catch&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;The results are the same as before:&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" color=red&gt;Msg 911, Level 16, State 1, Line 1&lt;BR&gt;Could not locate entry in sysdatabases for database 'WeatherData'. No entry found with that name. Make sure that the name is entered correctly.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;What happened? Some errors are not trapped by Try/Catch (see Books Online TRY...CATCH topic, Errors Unaffected by a TRY...CATCH Construct section). One category or error unaffected by Try/Catch is "&lt;EM&gt;Errors that occur during statement-level recompilation, such as object name resolution errors that occur after compilation because of deferred name resolution.&lt;/EM&gt;"&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Let's TRY Again&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;It's obvious we need another approach, Try/Catch just won't help here. We can check master.sys.databases for the WeatherData database using the following query:&lt;/P&gt;&lt;FONT face="Courier New"&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;
&lt;P&gt;Use&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;master&lt;BR&gt;Select&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;name&lt;BR&gt;From&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color=#008000&gt;&lt;FONT color=#008000&gt;sys.databases&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;Where&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;name&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color=#808080&gt;&lt;FONT color=#808080&gt;=&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color=#ff0000&gt;&lt;FONT color=#ff0000&gt;'WeatherData'&lt;/P&gt;&lt;/FONT&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;/FONT&gt;This is&amp;nbsp;a better test.&amp;nbsp;We want to test for the existence of the database on this instance of SQL Server, and this does just that. Let's wrap it in a conditional statement that reports the results of the test:&amp;nbsp;&lt;/P&gt;&lt;FONT face="Courier New"&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;
&lt;P&gt;Use&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;master&lt;BR&gt;If&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color=#808080&gt;&lt;FONT color=#808080&gt;Exists(&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;Select&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;name&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; From&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color=#008000&gt;&lt;FONT color=#008000&gt;sys.databases&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Where&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;name&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color=#808080&gt;&lt;FONT color=#808080&gt;=&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color=#ff0000&gt;&lt;FONT color=#ff0000&gt;'WeatherData'&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#808080&gt;&lt;FONT color=#808080&gt;)&lt;BR&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;Print&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color=#ff0000&gt;&lt;FONT color=#ff0000&gt;'Success: WeatherData exists.'&lt;/FONT&gt;&lt;/FONT&gt; &lt;BR&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;Else&lt;BR&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;Print&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color=#ff0000&gt;&lt;FONT color=#ff0000&gt;'Failure: WeatherData does not exist.'&lt;/P&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;
&lt;P&gt;Executing this script reports the result:&lt;/P&gt;&lt;FONT face="Courier New"&gt;
&lt;P&gt;Failure: WeatherData does not exist.&lt;/P&gt;&lt;/FONT&gt;
&lt;P&gt;Again, the test returns a Failure result, which is exactly what we want. I like this test. Let's keep it.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Next Step: Create the Database&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Next, let's write a re-executable T-Sql statement to create the database. I like the test code so much, I'm going to re-use it to make the Create Database statement re-executable:&lt;/P&gt;&lt;FONT face="Courier New"&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;
&lt;P&gt;If&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color=#808080&gt;&lt;FONT color=#808080&gt;Not&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color=#808080&gt;&lt;FONT color=#808080&gt;Exists(&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;Select&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;name&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;From&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color=#008000&gt;&lt;FONT color=#008000&gt;sys.databases&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;Where&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;name&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color=#808080&gt;&lt;FONT color=#808080&gt;=&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color=#ff0000&gt;&lt;FONT color=#ff0000&gt;'WeatherData'&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#808080&gt;&lt;FONT color=#808080&gt;)&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;Create&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;Database&lt;/FONT&gt;&lt;/FONT&gt; WeatherData&lt;BR&gt;go&lt;/P&gt;&lt;/FONT&gt;&lt;/FONT&gt;
&lt;P&gt;&lt;STRONG&gt;Re-Test&lt;/STRONG&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Finally, we'll re-execute the test &lt;EM&gt;after&lt;/EM&gt; creating the database. Why? Having the test fail is the first step in Test-Driven Database Development. After we meet the condition under test (or attempt to meet it), we need to re-execute the test to determine if we have accomplished the task under test. &lt;/P&gt;
&lt;P&gt;When complete, my test-driven T-Sql looks like this:&amp;nbsp;&lt;FONT face="Courier New"&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;&lt;/P&gt;
&lt;P&gt;Use&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;master&lt;BR&gt;If&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color=#808080&gt;&lt;FONT color=#808080&gt;Exists(&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;Select&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;name&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; From&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color=#008000&gt;&lt;FONT color=#008000&gt;sys.databases&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Where&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;name&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color=#808080&gt;&lt;FONT color=#808080&gt;=&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color=#ff0000&gt;&lt;FONT color=#ff0000&gt;'WeatherData'&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#808080&gt;&lt;FONT color=#808080&gt;)&lt;BR&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;Print&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color=#ff0000&gt;&lt;FONT color=#ff0000&gt;'Success: WeatherData exists.'&lt;/FONT&gt;&lt;/FONT&gt; &lt;BR&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;Else&lt;BR&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;Print&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color=#ff0000&gt;&lt;FONT color=#ff0000&gt;'Failure: WeatherData does not exist.'&lt;/P&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;
&lt;P&gt;If&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color=#808080&gt;&lt;FONT color=#808080&gt;Not&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color=#808080&gt;&lt;FONT color=#808080&gt;Exists(&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;Select&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;name&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;From&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color=#008000&gt;&lt;FONT color=#008000&gt;sys.databases&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;Where&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;name&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color=#808080&gt;&lt;FONT color=#808080&gt;=&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color=#ff0000&gt;&lt;FONT color=#ff0000&gt;'WeatherData'&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#808080&gt;&lt;FONT color=#808080&gt;)&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;Create&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;Database&lt;/FONT&gt;&lt;/FONT&gt; WeatherData&lt;BR&gt;go&amp;nbsp;&lt;FONT face="Courier New"&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;&lt;/P&gt;
&lt;P&gt;Use&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;master&lt;BR&gt;If&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color=#808080&gt;&lt;FONT color=#808080&gt;Exists(&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;Select&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;name&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; From&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color=#008000&gt;&lt;FONT color=#008000&gt;sys.databases&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Where&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;name&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color=#808080&gt;&lt;FONT color=#808080&gt;=&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color=#ff0000&gt;&lt;FONT color=#ff0000&gt;'WeatherData'&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#808080&gt;&lt;FONT color=#808080&gt;)&lt;BR&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;Print&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color=#ff0000&gt;&lt;FONT color=#ff0000&gt;'Success: WeatherData exists.'&lt;/FONT&gt;&lt;/FONT&gt; &lt;BR&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;Else&lt;BR&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;Print&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color=#ff0000&gt;&lt;FONT color=#ff0000&gt;'Failure: WeatherData does not exist.'&lt;/P&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;
&lt;P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;/FONT&gt;This returns the following results:&lt;/P&gt;&lt;FONT face="Courier New"&gt;
&lt;P&gt;Failure: WeatherData does not exist.&lt;BR&gt;Success: WeatherData exists.&lt;/P&gt;&lt;/FONT&gt;
&lt;P&gt;
&lt;P&gt;Cool.&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Kicking It&amp;nbsp;Up Another Notch&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;This is good, but we can make it even better.&lt;/P&gt;
&lt;P&gt;First, save the test query alone as the file Test_CreateWeatherData.db.sql:&amp;nbsp;&lt;FONT face="Courier New"&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;&lt;/P&gt;
&lt;P&gt;Use&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;master&lt;BR&gt;If&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color=#808080&gt;&lt;FONT color=#808080&gt;Exists(&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;Select&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;name&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; From&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color=#008000&gt;&lt;FONT color=#008000&gt;sys.databases&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Where&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;name&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color=#808080&gt;&lt;FONT color=#808080&gt;=&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color=#ff0000&gt;&lt;FONT color=#ff0000&gt;'WeatherData'&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#808080&gt;&lt;FONT color=#808080&gt;)&lt;BR&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;Print&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color=#ff0000&gt;&lt;FONT color=#ff0000&gt;'Success: WeatherData exists.'&lt;/FONT&gt;&lt;/FONT&gt; &lt;BR&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;Else&lt;BR&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;Print&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color=#ff0000&gt;&lt;FONT color=#ff0000&gt;'Failure: WeatherData does not exist.'&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/FONT&gt;
&lt;P&gt;Next, create a new query named CreateWeatherData.db.sql in Solution Explorer&amp;nbsp;with the following T-Sql statements:&lt;/P&gt;&lt;FONT face="Courier New"&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;
&lt;P&gt;Use&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=+0&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;master&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=+0&gt;go&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;&lt;BR&gt;Print&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=+0&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000&gt;&lt;FONT color=#ff0000&gt;''&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;Print&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=+0&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000&gt;&lt;FONT color=#ff0000&gt;'Create WeatherData database'&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;&lt;BR&gt;If&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=+0&gt; &lt;/FONT&gt;&lt;FONT color=#808080&gt;&lt;FONT color=#808080&gt;Not&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=+0&gt; &lt;/FONT&gt;&lt;FONT color=#808080&gt;&lt;FONT color=#808080&gt;Exists(&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;Select&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=+0&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;name&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; From&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=+0&gt; &lt;/FONT&gt;&lt;FONT color=#008000&gt;&lt;FONT color=#008000&gt;sys.databases&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Where&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=+0&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;name&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=+0&gt; &lt;/FONT&gt;&lt;FONT color=#808080&gt;&lt;FONT color=#808080&gt;=&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=+0&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000&gt;&lt;FONT color=#ff0000&gt;'WeatherData'&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#808080&gt;&lt;FONT color=#808080&gt;)&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;begin&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp; Print&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=+0&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000&gt;&lt;FONT color=#ff0000&gt;' &amp;gt; Creating WeatherData database.'&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp; Create&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=+0&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;Database&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=+0&gt; WeatherData&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;end&lt;BR&gt;Else&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;Print&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=+0&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000&gt;&lt;FONT color=#ff0000&gt;' &amp;gt; WeatherData database exists.'&lt;/P&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;
&lt;P&gt;Save the CreateWeatherData.db.sql script.&lt;/P&gt;
&lt;P&gt;Finally, create one more script in the database project named DeployV1.ver.sql containing the following T-Sql statements:&lt;/P&gt;&lt;FONT face="Courier New"&gt;&lt;FONT color=#008000&gt;&lt;FONT color=#008000&gt;
&lt;P&gt;/*&lt;BR&gt;&lt;BR&gt;&amp;nbsp;Notes:&lt;BR&gt;&lt;BR&gt;&amp;nbsp;1. Turn on SQLCMD mode.&lt;BR&gt;&lt;BR&gt;&amp;nbsp;2. If you receive an error like "Incorrect syntax near ':'",&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; see Note 1.&lt;BR&gt;&lt;BR&gt;&amp;nbsp;3. Correct the file paths, replacing the default&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; with the full path to your files.&lt;BR&gt;&lt;BR&gt;*/&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;&lt;BR&gt;Print&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=+0&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000&gt;&lt;FONT color=#ff0000&gt;''&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;Print&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=+0&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000&gt;&lt;FONT color=#ff0000&gt;'Deploying WeatherData v1.'&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;&lt;BR&gt;Print&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=+0&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000&gt;&lt;FONT color=#ff0000&gt;''&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;Print&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=+0&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000&gt;&lt;FONT color=#ff0000&gt;'Calling Test_CreateWeatherData.db.sql...'&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=+0&gt;:r "C:\Projects\WeatherData\WeatherData\Test_CreateWeatherData.db.sql"&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;Print&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=+0&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000&gt;&lt;FONT color=#ff0000&gt;'Test_CreateWeatherData.db.sql called.'&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;&lt;BR&gt;Print&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=+0&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000&gt;&lt;FONT color=#ff0000&gt;''&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;Print&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=+0&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000&gt;&lt;FONT color=#ff0000&gt;'Calling CreateWeatherData.db.sql...'&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=+0&gt;:r "C:\Projects\WeatherData\WeatherData\CreateWeatherData.db.sql"&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;Print&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=+0&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000&gt;&lt;FONT color=#ff0000&gt;'CreateWeatherData.db.sql called.'&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;&lt;BR&gt;Print&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=+0&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000&gt;&lt;FONT color=#ff0000&gt;''&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;Print&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=+0&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000&gt;&lt;FONT color=#ff0000&gt;'Calling Test_CreateWeatherData.db.sql...'&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=+0&gt;:r "C:\Projects\WeatherData\WeatherData\Test_CreateWeatherData.db.sql"&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;Print&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=+0&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000&gt;&lt;FONT color=#ff0000&gt;'Test_CreateWeatherData.db.sql called.'&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;&lt;BR&gt;Print&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=+0&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000&gt;&lt;FONT color=#ff0000&gt;''&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#0000ff&gt;Print&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=+0&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000&gt;&lt;FONT color=#ff0000&gt;'WeatherData v1 deployed.'&lt;/P&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;
&lt;P&gt;Before executing this script, drop the WeatherData database (if you've created it). Also, follow the instructions in the comments. Turn on SQLCMD mode in SSMS. When you do this, the SqlCmd scripts will be highlighted in gray as shown:&lt;/P&gt;
&lt;P&gt;&lt;IMG src="http://vsteamsystemcentral.com/images/ext/WeatherData_0_11.jpg"&gt;&lt;/P&gt;
&lt;P&gt;Execute the DeployV1.ver.sql script. If all goes as planned, you should see the following results:&lt;/P&gt;&lt;FONT face="Courier New"&gt;
&lt;P&gt;Deploying WeatherData v1.&lt;BR&gt;&lt;BR&gt;Calling Test_CreateWeatherData.db.sql...&lt;BR&gt;Failure: WeatherData does not exist.&lt;BR&gt;Test_CreateWeatherData.db.sql called.&lt;BR&gt;&lt;BR&gt;Calling CreateWeatherData.db.sql...&lt;BR&gt;&lt;BR&gt;Create WeatherData database&lt;BR&gt;&amp;gt; Creating WeatherData database.&lt;BR&gt;CreateWeatherData.db.sql called.&lt;BR&gt;&lt;BR&gt;Calling Test_CreateWeatherData.db.sql...&lt;BR&gt;Success: WeatherData exists.&lt;BR&gt;Test_CreateWeatherData.db.sql called.&lt;BR&gt;&lt;BR&gt;WeatherData v1 deployed.&lt;/P&gt;&lt;/FONT&gt;
&lt;P&gt;&lt;STRONG&gt;Q &amp;amp; A&lt;/STRONG&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I hear you thinking: "Andy, this was a lot more work than simply executing a Create Database statement." I agree. This is an example of Test-Driven Database Development. It's a good demonstration of the amount of additional work required to accomplish TD3. &lt;/P&gt;
&lt;P&gt;"So why in the world would we do this?" I am so glad you asked that question! &lt;/P&gt;
&lt;P&gt;While this is extra work for the first version of the database, the Unit Test developed here will live on as a Regression Test for the remainder of this database's lifecycle. &lt;/P&gt;
&lt;P&gt;"Why not backup and restore the database?" You can do that. It works in many scenarios but not all. Remote deployment, for instance. Scripting the database will work wherever restoring a backup will work, but the opposite doesn't always hold. &lt;/P&gt;
&lt;P&gt;If you use source or version control, there is some value in comparing scripts. If you don't use source or version control, I predict you will one day. &lt;/P&gt;
&lt;P&gt;Make no mistake, there are other ways to accomplish everything I've demonstrated here. There are some fantastic tools out there that help accomplish these tasks. I'll write about them soon.&lt;/P&gt;
&lt;P&gt;:{&amp;gt; Andy&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://vsteamsystemcentral.com/cs21/aggbug.aspx?PostID=394" width="1" height="1"&gt;</description><category domain="http://vsteamsystemcentral.com/cs21/blogs/applied_database_development/archive/tags/WeatherData/default.aspx">WeatherData</category><category domain="http://vsteamsystemcentral.com/cs21/blogs/applied_database_development/archive/tags/Test-Driven+Database+Development/default.aspx">Test-Driven Database Development</category></item><item><title>Tricks and Gotchas of Logon Triggers, or, Let Me In, Stupid DAC</title><link>http://vsteamsystemcentral.com/cs21/blogs/timbenninghoff/archive/2009/07/27/tricks-and-gotchas-of-logon-triggers.aspx</link><pubDate>Tue, 28 Jul 2009 01:16:00 GMT</pubDate><guid isPermaLink="false">d291d4df-cf3d-4686-b1b1-8a0a96a3a0a7:472</guid><dc:creator>timbenninghoff</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;The internet abounds with documentation and blog posts about logon triggers, introduced to SQL Server 2005 in service pack 2.&amp;nbsp; Recently I had the opportunity to work with them developing an imperfect solution to provide a temporary bandage for a vendor's poor SQL security design; a recipe for delving into the dusty, forgotten corners of the functionality.&amp;nbsp; From that experience, combined with some help from &lt;a href="http://msdn.microsoft.com/en-us/library/bb153915.aspx"&gt;Books Online&lt;/a&gt;, I've come away with a couple hints and tips, all of which were tested on SQL Server 2005 SP2.&lt;br&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&amp;nbsp;Errors In Your Trigger Can Prevent Everyone From Connecting&lt;/b&gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;Let's say you've created a trigger, but made the mistake of referencing a table that doesn't exist in the trigger's logic.&amp;nbsp; Well, that error is going to prevent anyone, even administrators, from connecting to the server because of the trigger execution.&amp;nbsp; Yikes!&lt;/p&gt;&lt;p&gt;Failures to connect to SQL Server because of a logon trigger are logged to your SQL log file.&amp;nbsp; Fortunately, an error like a non-existent table will also show up in the log file as part of that logon trigger failure to connect.&amp;nbsp; You should be able to use this to give you clues on how to fix your logon trigger.&lt;br&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;b&gt;Know How You Are Going to Disable the Trigger&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;So, you probably already know that you can use a DAC (Dedicated Administrator Connection) to get into SQL Server, but it's a little more complicated than just using admin:&amp;lt;server name&amp;gt;.&amp;nbsp; You're probably panicking because you've launched SSMS and are trying to connect using admin:&amp;lt;server name&amp;gt;, but you keep getting a message saying 'Dedicated administrator connections are not support. (ObjectExplorer)'.&amp;nbsp; Reading closely you'll see that you can't use Object Explorer with a DAC.&amp;nbsp; Trying connecting via a Query instead.&lt;/p&gt;&lt;p&gt;If you're DBA who doesn't have access to the server on which SQL Server resides, you'll want to make sure you have remote DAC enabled on your server before you start your logon trigger work, either via the SQL Server Surface Area Configuration for Features or sp_configure.&lt;br&gt;&lt;/p&gt;&lt;p&gt;Also, if you try to connect via a DAC and see this error message from SSMS:&lt;/p&gt;&lt;p&gt;&amp;nbsp;A connection was successfully established with the server, but then an error occurred during the login process. (provider: TCP Provider, error: 0 - An established connection was aborted by the software in your host machine.) (Microsoft SQL Server, Error : 10053)&lt;br&gt;&lt;/p&gt;&lt;p&gt;or this error message from sqlcmd:&lt;/p&gt;&lt;p&gt;HResult 0x2745, Level 16, State 1&lt;/p&gt;&lt;p&gt;TCP Provider:&amp;nbsp; An established connection was aborted by the software in your host machine.&amp;nbsp; Sqlcmd:&amp;nbsp; Error:&amp;nbsp; Microsoft SQL Native Client : Communication link failure.&lt;/p&gt;&lt;p&gt;...then it means that one of your co-workers, or your evil subconscious, have already made the single DAC connection allowed to a server, and you'll have to track them down and wrestle the DAC away from them.&lt;/p&gt;&lt;p&gt;If you don't have SQL Browser running, you might not be able to connect via a DAC either, receiving some long error about the SQL Browser and port numbers in sqlcmd, or in SSMS about a 'network-related or instance-specific error'.&amp;nbsp; In this case, you'll need to check your SQL error log to find the port that the DAC is listening on, and then use sqlcmd -S&amp;lt;server IP&amp;gt;,&amp;lt;port&amp;gt; to connect to the server.&lt;br&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&amp;nbsp;Know How To Find The Triggers&lt;/b&gt; &lt;br&gt;&lt;/p&gt;&lt;p&gt;If you use descriptive names like me and can't remember the exact spelling, you need to be able to find the exact name of the trigger once you've connected via a DAC.&amp;nbsp; The system view sys.server_triggers is your friend.&amp;nbsp; Armed with the name of your logon trigger from this view, DISABLE TRIGGER &amp;lt;trigger name&amp;gt; ON ALL SERVER will help you out of your jam.&amp;nbsp; Or, if you're feeling particular vindictive, DROP TRIGGER &amp;lt;trigger name&amp;gt; ON ALL SERVER will work too.&lt;/p&gt;&lt;p&gt;&amp;nbsp;What if you have multiple logon triggers and don't know which one is stopping you?&amp;nbsp; I'm afraid you'll have to use a process of elimination and the sys.server_triggers.is_disabled column to help you keep track of where you are at.&amp;nbsp; &lt;/p&gt;&lt;p&gt;Although, there is a way to create your logon trigger so that it both prevents a user from connecting AND logs that failed connection to a table you create.&amp;nbsp; That sounds like a good topic for my next blog post. &lt;/p&gt;&lt;p&gt;&amp;nbsp;Thanks go out to @MladenPrajdic and @afernandez on Twitter, both very smart, helpful people whom you should follow, for the inspiration for this post.&lt;br&gt;&lt;/p&gt;&lt;img src="http://vsteamsystemcentral.com/cs21/aggbug.aspx?PostID=472" width="1" height="1"&gt;</description><category domain="http://vsteamsystemcentral.com/cs21/blogs/timbenninghoff/archive/tags/Sql+Server+2005/default.aspx">Sql Server 2005</category></item><item><title>Electronic Arts and "Sin To Win"</title><link>http://vsteamsystemcentral.com/cs21/blogs/andynontech/archive/2009/07/25/electronic-arts-and-sin-to-win.aspx</link><pubDate>Sat, 25 Jul 2009 17:28:00 GMT</pubDate><guid isPermaLink="false">d291d4df-cf3d-4686-b1b1-8a0a96a3a0a7:471</guid><dc:creator>andy</dc:creator><slash:comments>0</slash:comments><description>&lt;P&gt;&lt;STRONG&gt;Introduction&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;(Found via &lt;A href="http://twitter.com/brett" target=_blank&gt;Brett Petersel&lt;/A&gt;, &lt;A href="http://twitter.com/" target=_blank&gt;Twitter&lt;/A&gt;) So, EA is publicizing a new game called Dante's Inferno, and they chose a contest at Comic-Con to promote it: &lt;A href="http://www.sintowin.me/" target=_blank&gt;Sin to Win&lt;/A&gt;. There's a decent synopsis &lt;A href="http://mashable.com/2009/07/25/danteteam-contest/" target=_blank&gt;here&lt;/A&gt;.&amp;nbsp;Take a picture with a "booth babe" at Comic-Con, tweet about it with the hashtag #lust, repeat the process.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Executive Summary&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Bad idea.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Detailed Analysis&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;This is a contest sponsored to promote the game? They're only at the second circle - what happens when they get to the seventh (the violent)? &lt;/P&gt;
&lt;P&gt;You know, maybe&amp;nbsp;it's true that "all publicity is good publicity." I wouldn't know. I haven't gone after bad publicity intentionally, so it could be that I'm just missing out. &lt;/P&gt;
&lt;P&gt;I don't think the single act of the contest was a disaster. No, they've put a lot of effort into spinning this into the&amp;nbsp;PR nightmare it has become. Their reactions - and make no mistake, these are reactions - are worded in the vein "We know you're upset but that's your problem." Take &lt;A href="http://twitpic.com/bityg" target=_blank&gt;this image&lt;/A&gt;, for instance, posted at twitpic:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;IMG src="http://vsteamsystemcentral.com/images/ext/dantePRDisaster_0.bmp"&gt;&lt;/P&gt;
&lt;P&gt;I grabbed this image because &lt;A href="http://twitpic.com/bi18o" target=_blank&gt;similar messages posted at TwitPic&lt;/A&gt;&amp;nbsp;have disappeared. I'm not confused by what EA did, and neither are the people who are complaining. I understand &lt;EM&gt;exactly&lt;/EM&gt; what they want folks to do in this contest. Side-stepping the issue isn't working out well here. And it's difficult to take an apology for the offense seriously when the contest hasn't been&amp;nbsp;cancelled.&lt;/P&gt;
&lt;P&gt;Here's hoping they stop now, seriously analyze where the money for purchasing video games originates (in families), admit their utter fallacy, and identify and promise to counsel the marketeers involved.&lt;/P&gt;
&lt;P&gt;Andy&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://vsteamsystemcentral.com/cs21/aggbug.aspx?PostID=471" width="1" height="1"&gt;</description><category domain="http://vsteamsystemcentral.com/cs21/blogs/andynontech/archive/tags/EMPs+_2800_Expensive+Management+Practices_2900_/default.aspx">EMPs (Expensive Management Practices)</category></item></channel></rss>