The first is the most traditional way of writing, using variables in the stored procedure as a paging multiplier
Copy Code code as follows:
[C-sharp] View plaincopyprint?create proc P_paged1
@pageSize int, @currentPage int
As
Select Top (@pageSize) * FROM student
where ID not in
(select Top (@pageSize * (@currentPage-1)) ID from student)
Go
EXEC p_paged1 2,3
Create proc P_paged1
@pageSize int, @currentPage int
As
Select Top (@pageSize) * FROM student
where ID not in
(select Top (@pageSize * (@currentPage-1)) ID from student)
Go
EXEC p_paged1 2,3
--sql Server2005 Subsequent paging statements
Copy Code code as follows:
[C-sharp] View plaincopyprint?create proc P_PAGED2
@pageStart int, @page End int
As
Select * FROM
(select *,row_number ()-desc) as Rnum
from student) t Br>where t.rnum between @pageStart and @pageEnd
Go
exec p_paged2 5,10