• 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 总页数

  • 相关阅读:
    图论小测
    有关连通性
    差分约束
    php中代码执行&&命令执行函数【转载】
    Boss直聘的一个csrf与url跳转漏洞(已经修复)
    Immunity Canvas初体验加操作指南
    SSRF复习版本
    XXE漏洞复习版本
    信息收集汇总
    web前端逆向初体验
  • 原文地址:https://www.cnblogs.com/li1999/p/13446500.html
Copyright © 2020-2023  润新知