title: How to sum the columns of the temporary table?
body: <p>In SQL Server,  I am inserting a row in a temporary table, and I am trying to sum the total of the columns at the end of the table. How can I do that?</p>
  
  <p>In my temp tables, columns are dynamically created. How can I sum the columns now?</p>
  
  <p>This is my query</p>
  
  <pre><code> select * from #TempTable 
   union all 
   select SUM(2008),SUM(2009),SUM(2010),SUM(2011) from #TempTable 
  </code></pre>
  
  <p>but it is giving an error:</p>
  
  <blockquote>
    <p>invalid column name 2008,2009,2010,2011 </p>
  </blockquote>