title: Preserving ORDER BY in SELECT INTO
body: <p>I have a T-SQL query that takes data from one table and copies it into a new table but only rows meeting a certain condition:</p>
  
  <pre><code>SELECT VibeFGEvents.* 
  INTO VibeFGEventsAfterStudyStart 
  FROM VibeFGEvents
  LEFT OUTER JOIN VibeFGEventsStudyStart
  ON 
      CHARINDEX(REPLACE(REPLACE(REPLACE(logName, 'MyVibe ', ''), ' new laptop', ''), ' old laptop', ''), excelFilename) &gt; 0
      AND VibeFGEventsStudyStart.MIN_TitleInstID &lt;= VibeFGEvents.TitleInstID
      AND VibeFGEventsStudyStart.MIN_WinInstId &lt;= VibeFGEvents.WndInstID
  WHERE VibeFGEventsStudyStart.excelFilename IS NOT NULL
  ORDER BY VibeFGEvents.id
  </code></pre>
  
  <p>The code using the table relies on its order, and the copy above does not preserve the order I expected. I.e. the rows in the new table <code>VibeFGEventsAfterStudyStart</code> are not monotonically increasing in the <code>VibeFGEventsAfterStudyStart.id</code> column copied from <code>VibeFGEvents.id</code>.</p>
  
  <p>In T-SQL how might I preserve the ordering of the rows from <code>VibeFGEvents</code> in <code>VibeFGEventsStudyStart</code>?</p>