zoukankan      html  css  js  c++  java
  • sjk 分页

    create database DB_8_6
    use DB_8_6

    create table Address
    (
    Aid int primary key identity,
    Aname varchar(40)
    )
    insert into Address values('河南');
    insert into Address values('上海');
    insert into Address values('北京');
    select * from Address

    create table Student
    (
    Sid int primary key identity,
    Sname varchar(40),
    Sex varchar(40),
    Sage int,
    Aid int
    )
    insert into Student values('张三','男','19','1');
    insert into Student values('李四','男','20','2');
    insert into Student values('王红','女','22','3');
    select * from Student s join Address a on s.Aid=a.Aid

    create proc Proc_Page
    @PageIndex int,
    @PageSize int,
    @Count int output
    as
    begin
    begin tran

    commit tran
    select @Count =COUNT(*) from Student
    declare @PageCount int

    if(@PageIndex < 1)
    begin
    set @PageIndex = 1
    end
    if(@PageCount % @PageSize = 0)
    begin
    select @PageCount =@PageCount / @PageSize
    end
    if(@PageCount % @PageSize = 1)
    begin
    select @PageCount =@PageCount /@PageSize+1
    end
    if(@PageIndex >@PageCount)
    begin
    set @PageIndex =@PageCount
    end

    select * from
    (select ROW_NUMBER() over(order by Sid) as RowT,* from Student)
    as Wpage join Address a on a.Aid=Wpage.Sid where RowT between
    (@PageIndex -1) * @PageSize and @PageSize
    end

    drop proc Proc_Page

    declare @a int
    declare @b int
    exec Proc_Page 1,2,@a out
    select @a 总页数

  • 相关阅读:
    使用基本的socket函数
    ODBC、ADO
    MFC开发ActiveX控件的简介
    MFC线程
    系统API函数实现多线程及线程同步
    IP地址控件
    加速键
    属性页对话框
    Tab控件
    树控件
  • 原文地址:https://www.cnblogs.com/li1999/p/13446500.html
Copyright © 2011-2022 走看看