zoukankan
html css js c++ java
一个高效的数据分页的存储过程 可以轻松应付百万数据
CREATE
PROCEDURE
pageTest
--
用于翻页的测试
--
需要把排序字段放在第一列
(
@FirstID
nvarchar
(
20
)
=
null
,
--
当前页面里的第一条记录的排序字段的值
@LastID
nvarchar
(
20
)
=
null
,
--
当前页面里的最后一条记录的排序字段的值
@isNext
bit
=
null
,
--
true 1 :下一页;false 0:上一页
@allCount
int
output,
--
返回总记录数
@pageSize
int
output,
--
返回一页的记录数
@CurPage
int
--
页号(第几页)0:第一页;-1最后一页。
)
AS
if
@CurPage
=
0
begin
--
统计总记录数
select
@allCount
=
count
(ProductId)
from
Product_test
set
@pageSize
=
10
--
返回第一页的数据
select
top
10
ProductId,
ProductName,
Introduction
from
Product_test
order
by
ProductId
end
else
if
@CurPage
=-
1
select
*
from
(
select
top
10
ProductId,
ProductName,
Introduction
from
Product_test
order
by
ProductId
desc
)
as
aa
order
by
ProductId
else
begin
if
@isNext
=
1
--
翻到下一页
select
top
10
ProductId,
ProductName,
Introduction
from
Product_test
where
ProductId
>
@LastID
order
by
ProductId
else
--
翻到上一页
select
*
from
(
select
top
10
ProductId,
ProductName,
Introduction
from
Product_test
where
ProductId
<
@FirstID
order
by
ProductId
desc
)
as
bb
order
by
ProductId
end
查看全文
相关阅读:
Spring.Net + Ibatis.Net + Log4Net 结合搭的一个简单多层开发架子
驳网上常见的半调子程序员白痴言论
IT对联大汇总
ClassBase A = New ClassSon() 全面分析
C# 反射/映射学习
C++ 一般类型与变量
HttpModule是如何工作的(转自大牛)
SQL Server 中的嵌套事务与@@TranCount(转)
IT人不要一直做技术(转我也不知道转了几圈了)
kingcms的双重循环
原文地址:https://www.cnblogs.com/zzh/p/314035.html
最新文章
左脑与右脑,新手与专家--读《程序员的思维修炼》
吐嘈某“最美解析式大赛”
USM锐化之openCV实现,附赠调整对比度函数
DOS下批量改文件名
心目中的解谜游戏排行榜
正则表达式工具
c# 操作Xml中SelectSingleNode方法中的xpath用法
SQL Server:SQL 通配符
SQL Server:SQL Like 通配符特殊用法:Escape
我的四旋翼飞行器方案
热门文章
C#对游戏手柄的编程开发之阶段性总结(冠丽四通控)
基于WEB的网络视频监控方案
病毒trojan.win32.agent2.gbx和Trojan.Win32.Agent2.gwc的删除方法
Junit3.8(转载)
Joystick using C# (GUAN`LI) 之完成篇
The ONE Simulator Introduction (ONE)
51单片机解码GPS 1602显示
SetCooperativeLevel函数介绍(设置协作等级)
检测到Loaderlock的问题(转载)
隐式事务(转)
Copyright © 2011-2022 走看看