title: How to Pivot the Results of a Stored Procedure in SQL Server
body: <p>I have a stored procedure that returns data in the format of:</p>
  
  <pre><code>Date  |  Unit A Count  |  Unit B Count  |  Unit C Count
  2010  |         335    |          52    |         540
  2011  |         384    |          70    |         556
  2012  |         145    |          54    |         345
  </code></pre>
  
  <p>Internally this stored procedure makes a call to another stored procedure, so I can't nest it again.<br>
  What I'm after is a way to pivot the above output so it looks like this:</p>
  
  <pre><code>              |  2010  |  2011  |  2012
  Unit A Count  |   335  |   384  |   145
  Unit B Count  |    52  |    70  |    54
  Unit C Count  |   540  |   556  |   345
  </code></pre>
  
  <p>Edit: The StorProc is called with 3 parameters and I do need to keep the original output.</p>
  
  <p>Any ideas?</p>
  
  <p>I'm using SQL Server 2005, Visual Studio 2008, C# with the output going to an .aspx page.</p>