The first method is the most traditional method. The variable in the stored procedure is used as the page multiplier.
Copy codeThe Code is 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
-- Paging statement after SQL Server2005
Copy codeThe Code is as follows:
[C-sharp] view plaincopyprint? Create proc p_paged2
@ PageStart int, @ pageEnd int
As
Select * from
(Select *, row_number () over (order by id desc) as rnum
From student) t
Where t. rnum between @ pageStart and @ pageEnd
Go
Exec p_paged2 5, 10