title: Iterating through dates in SQL
body: <p>I have a table of data that looks a bit like this:</p>
  
  <pre><code>Name    StartTime              FinishTime              Work
  Bob     2010-08-03 08:00:00    2010-08-03 12:00:00     4
  Bob     2010-08-03 13:00:00    2010-08-03 16:00:00     3
  Pete    2010-08-04 08:00:00    2010-08-04 12:00:00     4
  Mark    2010-08-04 10:00:00    2010-08-04 12:00:00     2
  </code></pre>
  
  <p>None of these date ranges should ever span over midnight.<br>
  I want to write SQL that will give me the following output, given an input Start Date of 2010-08-02 and a Finish Date of 2010-08-05</p>
  
  <pre><code>Date          Name   TotalWork
  2010-08-03    Bob    7
  2010-08-03    Pete   3
  2010-08-04    Pete   4
  2010-08-04    Mark   2 
  </code></pre>
  
  <p>I could live with, and in fact may ultimately need, to have any days that do not have work associated also be represented in the results set, maybe as a row like this:</p>
  
  <pre><code>2010-08-05     NULL   0
  </code></pre>
  
  <p>I'm not quite sure how to iterate through dates in SQL in the same way that I would with other languages.</p>
  
  <p>To give this some context, the output of this will ultimately plug into a Stacked Chart .Net control.</p>
  
  <p>Could someone give me a clue, a link to a tutorial or some other help?  Otherwise I think I'll be fiddling with this for days!</p>
  
  <p>Thank you!</p>
  
  <p>Jonathan</p>