zoukankan      html  css  js  c++  java
  • Sql server动态加载存储过程--分页

    create procedure [dbo].[pro_getStu]
    (
    @pindex int,  --最小是1,第1页
    @psize int,
    @name nvarchar,
    @dbcount int out--总记录数
    )
    as
    begin

    -----取符合条件的记录信息总数量
    declare @Sqlcount NVARCHAR(MAX)
    SET @Sqlcount = N'SELECT @dbcount = COUNT(1) FROM DoFolder where 1=1 '
    if @name is not null
    begin
    set @Sqlcount+=' and [DoFolderName] like ''%'+@name+'%''';
    end
    EXEC SP_EXECUTESQL  @Sqlcount,N'@dbcount int output',@dbcount output

    -----取符合条件的记录信息
    declare @sql varchar(2000);
    set @sql='
    select * from 
    (
    select ROW_NUMBER() over(order by DoFolderName) as num,
    [DoFolderID],[DoFolderName],[ParentID]
    from DoFolder where 1=1 ';

    if @name is not null
    begin
    set @sql+='and [DoFolderName] like ''%'+@name+'%''';
    end

    set @sql +=') temptable
    --where num  between ((页码-1)*几条+1) and (页码*几条)
    where num  between '+ convert( varchar,(@pindex-1)*@psize+1) +' and '+ convert(varchar,@pindex*@psize);
    print(@sql);
    exec(@sql);

    end
  • 相关阅读:
    (转)C# DES
    (转)adb shell am 的用法
    (转)C# 解析 json
    (转)C#执行exe程序
    (转) C# textbox 限制输入问题
    (转)C# SSL-X509使用
    事务管理
    spring数据源
    2.spring 学习
    sonarqube 代码检查
  • 原文地址:https://www.cnblogs.com/huosanpie/p/9967501.html
Copyright © 2011-2022 走看看