title: Efficient way to check if a SQL query will return results
body: <p>I would like to write a query that simply returns 1 or 0 depending if there will be results. </p>
  
  <p>I am thinking to use this</p>
  
  <pre><code>IF EXISTS(
        select * from myTable 
        where id=7 and rowInsertDate BETWEEN '01/01/2009' AND GETDATE()
  )
  SELECT 1
  ELSE
  SELECT 0
  </code></pre>
  
  <p>That's the general premise.</p>
  
  <p>The final results will actually be a far more complex query, taking one to many parameters and the string built up and executed using sp_executesql</p>
  
  <p>My question is lets say the 'count' would return 376986 and takes 4 seconds to calculate. Is using the IF EXISTS going to stop as soon as it find 1 row that satisfies the criteria.</p>
  
  <p>I'm deciding wether to use IF EXISTS or just query the @@ROWCOUNT and see if it is greater than zero.</p>
  
  <p>I did try some tests and both pretty much ran at the same speed but in 2 years time when there's alot more data is it likely using IF EXISTS is going to be a performance gain or not?</p>
  
  <p>Thanks</p>