title: Need to start agent job and wait until completes and get success or failure
body: <p>I have been trying to find sample code with using SQL Server 2005, I need to start an Agent Job and wait until it finishes process and then get the success or failure.  </p>
  
  <p>I know that I can use </p>
  
  <pre><code>EXEC MSDB.dbo.sp_start_job @Job_Name = 'JobName' 
  </code></pre>
  
  <p>to start the job but I can't find any sample code to poll the <code>msdb.dbo.sp_help_job</code> to know when it is completed and then find out if it was successful or failed.</p>