title: How to insert the output of a SQL Query into a temporary table?
body: <p>I am using SQL Server 2012 and I want to perform the following operations using T-SQL:</p>
  
  <ol>
  <li><p>Create a temporary table (let's call it <code>#temptable</code>).</p></li>
  <li><p>Insert values from tables located in an existing database into
  <code>#temptable</code> using a <code>SELECT</code> statement.</p></li>
  <li><p>Write a <code>SELECT</code> statement that will query the <code>#temptable</code>.</p></li>
  </ol>
  
  <p>I have tried the following but it seems the syntax is not correct or perhaps what I am trying to do is not allowed.</p>
  
  <pre><code>USE MyDatabase
  
  CREATE TABLE #temptable
  GO
  
  INSERT INTO #TempTable
  SELECT  [Col A], [Col B], [Col C]
  
  FROM MYLIST
  
  WHERE [MONTH OF STAY] = '2018-03-01'
  
  AND [Property] = 'ABC'
  
  SELECT * FROM #temptable
  </code></pre>
  
  <p>How do I move forward with this?</p>