Skip to content

Instantly share code, notes, and snippets.

@mbalex99
Created September 3, 2013 20:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mbalex99/6429205 to your computer and use it in GitHub Desktop.
Save mbalex99/6429205 to your computer and use it in GitHub Desktop.
DECLARE @intPage int;
DECLARE @intPageSize int;
SET @intPage = 1;
SET @intPageSize = 20;
DECLARE @intStartRow int;
DECLARE @intEndRow int;
SET @intStartRow = (@intPage -1) * @intPageSize + 1;
SET @intEndRow = @intPage * @intPageSize;
WITH items AS
(SELECT *,
ROW_NUMBER() OVER(ORDER BY MsgBrdName DESC) as intRow,
COUNT(MsgBrdName) OVER() AS intTotalHits
FROM tbl_MsgBrd_MsgBrd)
SELECT * FROM items
WHERE intRow BETWEEN @intStartRow AND @intEndRow
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment