title: SQL Server (TSQL) - Is it possible to EXEC statements in parallel?
body: <p>SQL Server 2008 R2</p>
  
  <p>Here is a simplified example:</p>
  
  <pre><code>EXECUTE sp_executesql N'PRINT ''1st '' + convert(varchar, getdate(), 126) WAITFOR DELAY ''000:00:10'''
  EXECUTE sp_executesql N'PRINT ''2nd '' + convert(varchar, getdate(), 126)'
  </code></pre>
  
  <p>The first statement will print the date and delay 10 seconds before proceeding.
  The second statement should print immediately.</p>
  
  <p>The way T-SQL works, the 2nd statement won't be evaluated until the first completes. If I copy and paste it to a new query window, it will execute immediately. </p>
  
  <p>The issue is that I have other, more complex things going on, with variables that need to be passed to both procedures. </p>
  
  <p>What I am trying to do is:</p>
  
  <ul>
  <li>Get a record</li>
  <li>Lock it for a period of time </li>
  <li>while it is locked, execute some other statements against this record and the table itself</li>
  </ul>
  
  <p>Perhaps there is a way to dynamically create a couple of jobs?</p>
  
  <p>Anyway, I am looking for a simple way to do this without having to manually PRINT statements and copy/paste to another session.</p>
  
  <p>Is there a way to EXEC without wait / in parallel?</p>