title: How To Slow Down A SQL Query?
body: <p>As strange as it sounds I need to slow down a SQL query. Currently I'm using Microsoft SQL Server 2008 R2 on an in-house development server with the AdventureWorks database. I'm in the process of testing some code and the queries that I'm running are too fast no matter what I try!</p>
  
  <p>Basically I'm testing a cut-off feature and need a sufficiently long query to be able to cut it off before it completes.</p>
  
  <p>Unfortunately as it is a local installation there isn't a single query or large enough table in the AdventureWorks database to actually give me good data to work with. I've tried</p>
  
  <pre><code>WAITFOR DELAY '01:00'
  </code></pre>
  
  <p>Which worked great to just test to make sure it was working, but now I need to test to see if I can cut the data stream off mid-read. The WAITFOR statement doesn't do me justice in that respect because I need it to actively be retrieving data back from the server. My first intuition was to use convoluted calculations to slow it down, however even having SQL server multiply all the numerical values in the query by themselves 37 times only slowed down the query by milliseconds. The second thing I tried was embedding the <code>WAITFOR</code> statement in a sub-query but it appears you can't do that. Finally, the only thing I haven't tried is to execute multiple stored procedures and <code>WAITFOR</code> in between them, but I don't think that would work for what I need.</p>
  
  <p>I have to say, I'm impressed at how hard it is to make an absolutely terrible query when you're this close to the server. </p>
  
  <p>Is there any way I can slow down a query easily?</p>
  
  <p>Thank you!</p>