--提取分页数据,返回总记录数
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

  

最新文章

  1. ASP.NET使用Memcached
  2. bootstrap-datetime 的使用
  3. 《winform窗体应用程序》----------简易记事本
  4. 我的vim配置文件
  5. Java面向对象之多态
  6. Angular学习
  7. Java 默认/缺省 内存大小,如果没有 -Xms -Xmx
  8. RESTful Web Services测试工具推荐
  9. JS中删除字符串中的空格
  10. 没有指针的java语言
  11. 13_ServletContext对象
  12. VS 2015 update2 装xamarin后,编辑axml文件无智能提示的解决方法。
  13. python3可变与不可变数据类型
  14. <Win32_17>集音频和视频播放功能于一身的简易播放器
  15. sql语句中 limi的用法
  16. Linux系统C语言socket tcp套接字编程
  17. markdown编辑器的学习
  18. 暑假练习赛 007 A - Time
  19. 基于stm32智能车的设计(ucosiii)---北京之行
  20. Jenkins之定时构建

热门文章

  1. leetcode287 Find the Duplicate Number
  2. SourceInsight主题设置
  3. linux_base-f10-10_7 linuxulator is not (kld)loaded
  4. Spring MVC系列[2]——参数传递及重定向
  5. MySQL存储过程(批量生成论坛中发帖、回帖、主题等数据)
  6. codevs 1742 爬楼梯(水题日常)
  7. 通过90行代码学会HTML5 WebSQL的4种基本操作
  8. 理解Vue
  9. C#中加锁问题
  10. Pacman常用命令 文内搜索吧