title: How to pivot dynamically with date as column
body: <p>I have a table with product id's and names, and another table with the stock of these products on certain dates. Such as <code>Item1</code> had <code>6</code> stock on <code>1-1-2014</code> and <code>8</code> stock on <code>2-1-2014</code>.
  I'm trying to show these in a stored procedure so that it looks like a calendar, showing all the dates in a month and the stock available in the cells. What is the best way to show this?</p>
  
  <p><strong>For example:</strong></p>
  
  <pre><code>Name  | 1-1-2014 | 2-1-2014 | 3-1-2014 | 4-1-2014
  Item1 |     6    |     8    |          |    6
  Item2 |          |     2    |     1    |
  </code></pre>
  
  <p>Original tables - Names</p>
  
  <pre><code> ID |   Name 
    1 |  Item1
    2 |  Item2
  </code></pre>
  
  <p>Original tables - Stockdates</p>
  
  <pre><code> ID | NameID  | Stock |    Date 
    1 |    1    |   8   |  2-1-2014    
    2 |    2    |   2   |  4-1-2014 
  </code></pre>