title: Should all sub queries be replaced with temporary tables?
body: <p>I have been working on a solution (in SQL Server) where all the sub queries with no exception have been rewritten with temp tables in order to boost performance. </p>
  
  <p>To give an example, all the queries like this:</p>
  
  <pre><code>SELECT something 
  FROM (SELECT * FROM T1 WHERE condition1) 
  JOIN ...
  </code></pre>
  
  <p>have been rewritten to be like this:</p>
  
  <pre><code>SELECT * 
  INTO #tempTable 
  FROM T1 
  WHERE condition1
  
  SELECT something 
  FROM #tempTable  
  JOIN ...
  </code></pre>
  
  <p>It has also been suggested <a href="https://stackoverflow.com/a/16770129/1262198">here</a> that all sub queries should be avoided in favor of temp tables.</p>
  
  <p>Based on the given facts, Should all sub queries be replaced with temp table? If not when should one be considered over the other?</p>