SQL2012 分页(最新)
--提取分页数据,返回总记录数
ALTER procedure [dbo].[sp_Common_GetDataPaging_ReturnDataCount]
(
@SqlString varchar(max), --查询语句
@PageNumber int, --当前的页码
@PageSize int, --每页显示的数据量
@SequenceField varchar(100), --排序字段
@DataCount int out --总数据量
)
as
begin
DECLARE @SqlAll VARCHAR(MAX)
DECLARE @Sql1 VARCHAR(MAX)
SET @SqlAll= @SqlString IF(CHARINDEX('/*CreateSqlStringOut*/',@SqlAll)>0)
BEGIN
declare @Sql nvarchar(max)
SET @Sql=replace(@SqlAll,'/*CreateSqlStringOut*/','') +N' select @execusercreatesql = @sql2'
declare @execusercreatesql varchar(max)
exec sp_executesql @Sql,N'@execusercreatesql varchar(max) out',@execusercreatesql out
set @SqlString =@execusercreatesql
END --提取总记录数
declare @Sqlcount nvarchar(max)
set @Sqlcount = ISNULL(@Sql1,' ')+' '+N'select @countNum = count(1) from ('+@SqlString+') as aaaaaaaaa'
exec sp_executesql @Sqlcount,N'@countNum int out',@DataCount out declare @BNum int
declare @ENum int
declare @sql2 varchar(max)
set @BNum = (@PageNumber-1)*@PageSize
set @ENum = @PageNumber*@PageSize --IF(CHARINDEX('/*CreateSqlStringOut*/',@SqlAll)>0)
--begin
--SET @SqlString=replace(@SqlAll,'/*CreateSqlStringOut*/','')
--set @SqlString =' '+left(@SqlString,len(@SqlString)-1)+' order by '+@SequenceField+' offset '+convert(varchar(10),@BNum)+' row fetch next '+convert(varchar(10),@PageSize)+' rows only' +char(39)
--exec(@sql2)
-- end
-- else begin set @SqlString =' '+@SqlString+' order by '+@SequenceField+' offset '+convert(varchar(10),@BNum)+' row fetch next '+convert(varchar(10),@PageSize)+' rows only'
exec(@SqlString) --end end
SQL2012 分页(最新)的更多相关文章
- Sql2012新分页查询offset fetch Sql2005/2008的row_number
SQL2005/2008的Row_Number http://www.cnblogs.com/Snowfun/archive/2011/10/10/2205772.html 1.OFFSET和FETC ...
- 简单封装分页功能pageView.js
分页是一个很简单,通用的功能.作为一个有经验的前端开发人员,有义务把代码中类似这样公共的基础性的东西抽象出来,一来是改善代码的整体质量,更重要的是为了将来做类似的功能或者类似的项目,能减少不必要的重复 ...
- .NET 开源SqlServer ORM框架 SqlSugar 3.0 API
3.1.x ,将作为3.X系统的最后一个版本,下面将会开发 全新的功能 更新列表:https://github.com/sunkaixuan/SqlSugar/releases 优点: SqlSuga ...
- SQL2012新特性一次一个数据块----特殊的查询分页
对于数据库人员来说,在软件项目开发的过程中,或多或少的不可避免的就是经常遇到类似“UI查询结果设计”这样的说法,当听到UI设计的时候,多数人的第一反应是“靠!关我毛事!~这是其他人的问题!”. 然而, ...
- easyui中点击datagrid的分页刷新按钮,数据无法更新到最新状态
原因分析:点击刷新按钮是对当前页数据进行reload,因此所传的请求参数皆为上一次加载当前页的参数即datagrid的load方法中的参数,主要是因为请求的最终时间无法更新到最新状态 解决方案:对点击 ...
- SpringBoot Jpa 分页查询最新配置方式
这是已经被废弃的接口 Sort sort = new Sort(Sort.Direction.DESC,"bean类中字段"); //创建时间降序排序 Pageable pagea ...
- 最新 php oracle 数据库连接 数据库分页
php 5连接 oracle 10g php oracle 分页 <?php//buyicode studio 20/12/2009//总记录数$sql = "select ROWNU ...
- SQL2012通用分页存储过程
--提取分页数据,返回总记录数 Createprocedure [dbo].[sp_Common_GetDataPaging_ReturnDataCount] ( @SqlString varchar ...
- 分页sql写法【只用最新的】
offset m rows FETCH NEXT n ROWS ONLY m=(pageindex-1)*pagesize n=pagesize sql server 2012以上适用.
随机推荐
- CF1072B Curiosity Has No Limits
思路: 对于序列t,只要第一个数确定了,后续的数也随之确定了.枚举四种情况即可.实现: #include <iostream> #include <vector> using ...
- 学习笔记——Paint 1(MaskFilter)
对于Paint没有很好的深入的学习过,在工作之余再巩固巩固. 1.Paint的BlurMaskFilter(模糊效果) 自定义一个View继承View 重写里面的onDraw方法.这里直接上代码了: ...
- Linux下各文件夹的结构说明及用途介绍(转载)
linux下各文件夹的结构说明及用途介绍: /bin:二进制可执行命令. /dev:设备特殊文件. /etc:系统管理和配置文件. /etc/rc.d:启动的配 置文件和脚本. /home:用户主目录 ...
- moment算本月开始日期和结束日期
moment算本月开始日期和结束日期 1.引入moment.js var vStartDate=new moment().add('month',addMonth).format("YYYY ...
- MySQL主服务配置文件
[mysql]port=3306socket=/var/lib/mysql/mysql.sockdefault-character-set = utf8mb4 [mysqld]server-id = ...
- SQL中的动态语句执行--exec(@sqlstr)
begin drop table #tmptable declare @money ut_money set @money=1.2345 create table #tmptable ( je ut_ ...
- bat 符号说明
netstat -an|findstr 139 ipconfig/all findstr IP ipconfig/all |findstr 物理地址 定值选行 ipconf ...
- javascript单元测试框架mochajs详解(转载)
章节目录 关于单元测试的想法 mocha单元测试框架简介 安装mocha 一个简单的例子 mocha支持的断言模块 同步代码测试 异步代码测试 promise代码测试 不建议使用箭头函数 钩子函数 钩 ...
- hibernate3缓存(hibernate)
一级缓存:当应用程序调用Session 的save() .update() .savaeOrUpdate() .get() 或load() ,以及调用查询接口的list() .iterate() 或f ...
- shell脚本,按字母出现频率降序排序。
[root@localhost oldboy]# cat file the squid project provides a number of resources toassist users de ...