title: SQL Server creating a temporary table from another table
body: <p>I am looking to create a temporary table which is used as an intermediate table while compiling a report.</p>
  
  <p>For a bit of background I am porting a VB 6 app to .net </p>
  
  <p>To create the table I can use...</p>
  
  <pre><code>SELECT TOP 0 * INTO #temp_copy FROM temp;
  </code></pre>
  
  <p>This creates an empty copy of temp, But it doesn't create a primary key </p>
  
  <p>Is there a way to create a temp table plus the constraints?</p>
  
  <p>Should I create the constraints afterwards?</p>
  
  <p>Or am I better off just creating the table using create table, I didn't want to do this because there are 45 columns in the table and it would fill the procedure with a lot of unnecessary cruft.</p>
  
  <p>The table is required because a lot of people may be generating reports at the same time so I can't use a single intermediary table </p>