• 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

  • 相关阅读:
    Unity做AR
    Linux怎么安装vim编译器
    Linux命令之tar
    Linux命令之ln
    Linux命令之grep
    Linux命令之less
    Linux命令之cd
    Linux命令之ll
    Linux命令之cp
    Linux命令之rm
  • 原文地址:https://www.cnblogs.com/kongjie/p/13072119.html
Copyright © 2020-2023  润新知