Sql-简单分页
2024-10-21 04:02:13
create proc proc_searchuser
(
@username varchar(12),
@page int=1,
@pagesize int=3,
@totalcount int output
)
as
declare @totalsql nvarchar(512)
declare @sql varchar(4000)
if(ISNULL(@username,'')<>'')
begin
set @totalsql='select @totalcount=COUNT(*) from users where username like ''%'+@username+'%'''
end
else
begin
set @totalsql='select @totalcount=COUNT(*) from users'
end
exec sp_executesql @totalsql,N'@totalcount int output',@totalcount output
-------------分页--------------
if @page<=0 set @page=1
set @sql='select * from (select ROW_NUMBER() over(order by userid)rowNO,* from users where username like ''%'+@username+'%'')U
where U.rowNo BETWEEN '+str((@page-1)*@pagesize+1)+' AND ' +str(@page*@pagesize)
exec (@sql)
go
最新文章
- 【PHP设计模式 10_ShiPeiQi.php】适配器模式
- 教你50招提升ASP.NET性能(九):显式的使用using语句减少内存泄露
- Object -C NSSet -- 笔记
- Dubbo源码学习--注册中心分析
- linux 移除svn文件夹
- log4j:ERROR Category option "; 1 "; not a decimal integer.错误解决
- linux iscsi配置
- HOW to Use QP_PREQ_PUB.PRICE_REQUEST API to Price an Item
- 关于Random(47)与randon.nextInt(100)的区别
- Hive元数据找回
- asp微信支付代码证书文件post_url.aspx和post_url.aspx.cs源码下载
- PHP断言(ASSERT)的用法
- Django时区的解释
- 阿里云 RDS 与 DRDS 学习了解
- jms异步转同步调用实例
- 【Java】PreparedStatement VS Statement
- servlet07
- stdlib.h
- smtp outlook邮件发送非授权码模式
- 崩溃block
热门文章
- HDU1267 下沙的沙子有几粒? 基础DP
- 河南省第十届省赛 Intelligent Parking Building
- bzoj 1880 最短路
- lucene in action
- Appium+python自动化29-toast消息【转载】
- hadoop3.1 分布式集群部署
- std::string 字符串大小写转换(转)
- scrapy xpath 从response中获取li,然后再获取li中img的src
- 对DDD中领域服务的理解
- codeforces Round #440 A Search for Pretty Integers【hash/排序】