zoukankan      html  css  js  c++  java
  • sql数据库存储过程分页

    数据库STUDB 表student

    alter proc pageStu(@tableNanme nvarchar(20),@whereName nvarchar(200),@orderBy nvarchar(50),@pageIndex int,@pageSize int,@pageCount int out)
    as
    begin
    declare @stratCount int,@endCount int;
    declare @sqlWhere nvarchar(500);
    set @stratCount=(@pageIndex-1)*@pageSize+1;
    set @endCount=@stratCount+@pageSize-1;
    set @sqlWhere='select * from (select ROW_NUMBER() over (order by '+@orderBy+') as rowid, * from '+@tableNanme+' where 1=1) as t where t.rowid between '+TRIM(STR(@stratCount))+' and '+TRIM(STR(@endCount))+'';
    --
    declare @strCount nvarchar(200);
    set @strCount='select @pageCount=count(*) from '+@tableNanme+'';
    --
    exec sp_executesql @strCount,N'@pageCount int out',@pageCount out;
    exec(@sqlWhere);
    end
    declare @sqlcount int;
    exec pageStu 'student','','sid','1','3',@sqlcount out
    select @sqlcount

  • 相关阅读:
    vue 插件的使用 todolist案例
    vue 传值 混入mixin
    vue 生命周期函数
    vue 指令总结
    vue 其它的指令
    vue 监听数据变化的原理 表单数据的收集
    vue for循环中的key
    vue 学习
    vue 学习
    HDU 1029
  • 原文地址:https://www.cnblogs.com/kongjie/p/13072119.html
Copyright © 2011-2022 走看看