title: How to pass table name as parameter in select statement in SQL Sever
body: <p>Table:</p>
  
  <pre><code>Col 
  ------
  Table1 
  table2 
  table3
  </code></pre>
  
  <p>Query:</p>
  
  <pre><code>select count(*) 
  from @tablename
  </code></pre>
  
  <p>I wanted to pass <code>table1</code>, <code>table2</code>, <code>table3</code> as parameters for <code>@tablename</code> in the select query and get the count for each table</p>
  
  <p>Desired output:</p>
  
  <pre><code> 2 (table 1 count)  3 (table 2 count)  4 (table 3 count)
  </code></pre>