Use Limit in SQL 2005 , SQL 2008
Posted on Sunday, July 8, 2012
|
No Comments
declare @FROM int
declare @TO int
--set @offset = 2;
--set @limit = 5;
--declare @idxini int
--declare @idxfim int
--select @idxfim = @offset * @limit -- 2 * 5 = 10
--select @idxini = @idxfim - (@limit-1); -- 10 - (5-1) = 7
WITH paging AS
(
SELECT
ROW_NUMBER() OVER (order by ItemID) AS rowid, *
FROM vBasicSetupItem
)
select *
from paging
where rowid between @FROM and @TO
order by rowid;