hi Dinesh,
Try something like below. This SP takes the page number as an argument
and should give return back, rows to be displayed on that page.
create proc getPageWiseData
(
@pageNo int --# Pass the page number as an argument.
)
as
BEGIN
--# Page size defines the number of rows you are planning to show per page.
declare @pageSize int
select @pageSize = 10
--# variable to hold the first row number of the page.
declare @from int
select @from = ( @pageNo * @pageSize ) - ( @pageSize - 1 )
--# variable to hold last row number of the page.
declare @to int
select @to = ( @pageNo * @pageSize )
--# get the data into a temp table, with simulated rownum.
select rownum = identity(10) , * into #dataWithRownum from yourTable
--# select the data with the calculated range for first and last row on page.
select * from #dataWithRownum where rownum >= @from and rownum <= @to
END
You can further modifiy this SP, to according to your requirements.
I have also added this to my
SQL blog - pagination in sybase
;-)