title: SQL - how do I generate rows for each month based on date ranges in existing dataset?
body: <p>assume I have a dataset:</p>
  
  <pre><code>rowID |  dateStart  |   dateEnd  | Year | Month
  121   | 2013-10-03  | 2013-12-03 | NULL | NULL
  143   | 2013-12-11  | 2014-03-11 | NULL | NULL
  322   | 2014-01-02  | 2014-02-11 | NULL | NULL
  </code></pre>
  
  <p>And I want sql to generate the following datasource based on the dateStart and the dateEnd. Note the year and month grouping.</p>
  
  <pre><code>rowID |  dateStart  |   dateEnd  | Year | Month
  121   | 2013-10-03  | 2013-12-03 | 2013 |   10
  121   | 2013-10-03  | 2013-12-03 | 2013 |   11
  121   | 2013-10-03  | 2013-12-03 | 2013 |   12
  143   | 2013-12-11  | 2014-03-11 | 2013 |   12
  143   | 2013-12-11  | 2014-03-11 | 2014 |    1
  143   | 2013-12-11  | 2014-03-11 | 2014 |    2
  143   | 2013-12-11  | 2014-03-11 | 2014 |    3
  322   | 2014-01-02  | 2014-02-11 | 2014 |    1
  322   | 2014-01-02  | 2014-02-11 | 2014 |    2
  </code></pre>
  
  <p>I'm having a hard time wrapping my head around this one. Any ideas?</p>