title: Creating and Selecting table variables dynamically in SQL Server stored procedure?
body: <p>Please guide me how to create table variables dynamically. I know it can be like this:</p>
  
  <pre><code>DECLARE @people TABLE 
  ( 
      id INT, 
      name VARCHAR(32) 
  );
  </code></pre>
  
  <p>How I will create if dont know columns and data types. Scenario is I have to create table variable as per a physical tables and selct data into them, use them in SP and then return data in table variables to C# program. </p>
  
  <p>For example I have a table Employees. I want create a table variable with same structure as Employyes have. But mentioning columns take a lot time (as Employees have about 100 columns)</p>
  
  <p>Please advice.</p>