title: MS SQL Server 2008: Convert Individual Time Card Entries To Calendar
body: <p>I would like to create a time card view from individual time card entries in a SQL table. So the entry table looks something like:</p>
  
  <pre><code>LABORID  WORKORDERID  STARTDATE                 HOURS
  -----------------------------------------------------
  58       13           2014-07-01 00:00:00.000   3.00
  58       19           2014-07-07 00:00:00.000   3.00
  58       22           2014-07-17 00:00:00.000   8.00
  58       34           2014-08-05 00:00:00.000   3.00
  58       34           2014-08-05 00:00:00.000   5.00
  58       34           2014-08-07 00:00:00.000   8.00    
  </code></pre>
  
  <p>I would like to create a view that looks like:</p>
  
  <pre><code>LABORID  WORKORDERID  S     M     T     W     T     F     S
  -----------------------------------------------------
  58       13                       3
  58       19                                   3
  58       22                                   8
  58       34                       8           8
  </code></pre>
  
  <p>I know it's probably going to need a sum, group by and pivot in there but I am at a complete loss. I started down the road of making a calendar table S-S for the next 100 years with the dates in there but I couldn't figure out how to join this information to it.</p>
  
  <p><strong>UPDATE:</strong> </p>
  
  <p>So I am stuck with the part that I'd like the transactions to be on the same line if they are in the same week. The best answer gives me this: </p>
  
  <pre><code>58  34  2014-08-05  NULL    NULL    8.00    NULL    NULL    NULL    NULL
  58  34  2014-08-07  NULL    NULL    NULL    NULL    5.00    NULL    NULL
  </code></pre>
  
  <p>But I'd like them to be on the same line, because they are in the same week, something like this:</p>
  
  <p><code>58    34  2014-08-05  NULL    NULL    8.00    NULL    5.00    NULL    NULL</code></p>