title: How can I select the newest 40 records into a temp table?
body: <p>I would like to get the latest 40 records into a temp table, something like this:</p>
  
  <pre><code>SELECT * INTO #MY_TEMP
  FROM
    (
      SELECT TOP 40 *
      FROM SOME_TABLE
      ORDER BY RECORD_DATE DESC
    )
  </code></pre>
  
  <p>However I am getting an error:
  An ORDER BY clause is not allowed in a derived table.</p>
  
  <p>I saw a few workarounds mentioned on other postings, involving TOP PERCENT, but my select already uses a TOP and it is not working.</p>
  
  <p>How can I get these records into my temp table?</p>