title: How to get total row count while having top row filter
body: <p>I have a temporary table in my stored procedure and i am filling it will some select statement. At the end i have to select only a few top records to send to the UI. </p>
  
  <p>Is there any way i can get to know the total records but select on top few records. Means if i have 2515 records but i am selecting only top 1000 but still can get to know the total count.</p>
  
  <pre><code>SELECT TOP (@ROWS) * 
  FROM #tempMoveFinal 
  WHERE case_id = @case_id 
  ORDER BY last_update_date DESC, item_id
  </code></pre>
  
  <p>I tried putting all the records in another temp table without the top row clause and then selecting the total row count but it's making the search query slower.</p>
  
  <p>Is there any in-build function which can be used for this case?</p>