title: How to wait for a query to return results?
body: <p>Is it possible to have a query wait until it has results instead of returning immediately with an empty result set. For example:</p>
  
  <pre><code>SELECT Column1 FROM Table1
  </code></pre>
  
  <p>If <code>Table1</code> is empty, the query would return with an empty result set. However, I want it to not return, but wait until at least one row is available, preferably with a timeout of some sort. I would prefer to do this without involving Service Broker into the equation, if possible.</p>
  
  <p><strong>Clarification:</strong></p>
  
  <p>CLR is enabled on the server, but the call is coming from a platform independent C++ program via SQLAPI++/ODBC. So, no C#/.NET tricks are possible. The goal is to make a call into a stored procedure, specify a timeout and not return until data is available (and returned by the stored proc) or the specified timeout expires.</p>
  
  <p>For example:</p>
  
  <pre><code>EXEC GetData @Timeout=2000 -- Wait for upto 5000 milliseconds for a result set to be 
                             -- available
  </code></pre>