1 --------------------------------- SQL2000 --------------------------------
2 Create procedure pagechange2005
3 (@ Pagesize Int ,
4 @ Pageindex Int )
5 As
6 Set Nocount on
7 Begin
8 Declare @ indextable table (ID Int Identity ( 1 , 1 ), NID Int )
9 Declare @ pagelowerbound Int
10 Declare @ pageupperbound Int
11 Set @ Pagelowerbound = (@ Pageindex - 1 ) * @ Pagesize
12 Set @ Pageupperbound = @ Pagelowerbound + @ Pagesize
13 Set Rowcount @ pageupperbound
14 Insert into @ indextable (NID) Select ID from testtable order by ID DESC
15 Select * From testtable o, @ indextable t Where O. ID = T. Nid
16 And T. ID between @ pagelowerbound + 1 And @ pageupperbound order by T. ID
17 End
18 Set Nocount off
19 --------------------------------- Sql2005 --------------------------------
20 Create procedure pagechange2005
21 (@ Pagesize Int ,
22 @ Pageindex Int )
23 As
24
25 Begin
26 With temptbl As (
27 Select row_number () over (order by id desc) as row, * From testtable)
28 Select * From temptbl Where Row between (@ pageindex - 1 ) * @ Pagesize + 1 And (@ pageindex - 1 ) * @ Pagesize + @ Pagesize
29 End
30