title: Rounding UP in SQL Server?
body: <p>I have written a paging system for sql server. and it works great but i am trying to return how many pages there are in total</p>
  
  <p>Hence if there are 5 records and 2 records per page then the total is 3 pages</p>
  
  <p>this is what i have</p>
  
  <pre><code>   SELECT @TotalPages = ( (SELECT COUNT(*) FROM #TempItems) / @RecsPerPage )
  </code></pre>
  
  <p>and my output parameter is defined like so</p>
  
  <pre><code>   @TotalPages AS INT OUT,
  </code></pre>
  
  <p>Now it sort of works :-)   in my test there are 5 records and 2 records per page so the above select returns 2 but its wrong it should be 3</p>
  
  <p>This is because its saying 5 / 2 = whole number 2... how do i round up...?</p>
  
  <p>I tired ceiling but couldn't get it to work..</p>
  
  <p>Any ideas?</p>
  
  <p>Thanks in advance</p>