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

最新文章

  1. 【PHP设计模式 10_ShiPeiQi.php】适配器模式
  2. 教你50招提升ASP.NET性能(九):显式的使用using语句减少内存泄露
  3. Object -C NSSet -- 笔记
  4. Dubbo源码学习--注册中心分析
  5. linux 移除svn文件夹
  6. log4j:ERROR Category option &quot; 1 &quot; not a decimal integer.错误解决
  7. linux iscsi配置
  8. HOW to Use QP_PREQ_PUB.PRICE_REQUEST API to Price an Item
  9. 关于Random(47)与randon.nextInt(100)的区别
  10. Hive元数据找回
  11. asp微信支付代码证书文件post_url.aspx和post_url.aspx.cs源码下载
  12. PHP断言(ASSERT)的用法
  13. Django时区的解释
  14. 阿里云 RDS 与 DRDS 学习了解
  15. jms异步转同步调用实例
  16. 【Java】PreparedStatement VS Statement
  17. servlet07
  18. stdlib.h
  19. smtp outlook邮件发送非授权码模式
  20. 崩溃block

热门文章

  1. HDU1267 下沙的沙子有几粒? 基础DP
  2. 河南省第十届省赛 Intelligent Parking Building
  3. bzoj 1880 最短路
  4. lucene in action
  5. Appium+python自动化29-toast消息【转载】
  6. hadoop3.1 分布式集群部署
  7. std::string 字符串大小写转换(转)
  8. scrapy xpath 从response中获取li,然后再获取li中img的src
  9. 对DDD中领域服务的理解
  10. codeforces Round #440 A Search for Pretty Integers【hash/排序】