Stored Procedure page

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.