SQL Server Pagination using CTE
You can certainly avoid a conditional here, but you also do not need either CEILING or conversion to numeric to get the total number of pages if both @totalrec and @pagesize are integers (and it seems safe to assume that they are). The following formula will give you the number of pages to accommodate @totalrec rows given the page size of @pagesize:

(@totalrec - 1) / @pagesize + 1 AS TotalPages