T-SQL 101: 17 Paginating rows returned from SQL Server T-SQL queries
When I need to display a potentially large number of rows on a screen, I often need to show them in pages. This is called paginating the rows.
For example, if I’m showing bank transactions, I might want to show 25 per page. The challenge is that I also need to be able to ask for a specific page number. So my query becomes: give me page 7 where there are 25 rows per page. In that case, I want to skip the first 150 rows, then ask for the next 25 rows.
2019-05-13