码迷,mamicode.com
首页 > 数据库 > 详细

sql分页demo

时间:2017-02-14 17:37:40      阅读:247      评论:0      收藏:0      [点我收藏+]

标签:where   arch   use   div   name   ase   oval   weight   alt   

ALTER proc [dbo].[ProcGetUserInfoPageInfoByUserName]
    @UserName varchar(200),
    @PageIndex int,    
    @PageSize int
as
Begin    
    select Row_Number()over(order by UserID)as RowNumber, UserID, UserName, 
    Mobile, WeixinID, Unit, IsReturnReceipt,‘‘ as RegionMap,IsPSUser,UserCode 
    into #Main
    from dbo.UserInfo
    where UserName like %+@UserName+% and Status=0
    
    select  UserID, UserName, Mobile, WeixinID, Unit, IsReturnReceipt, RegionMap,IsPSUser,UserCode ,(select count(1) as TotalCount from #Main) as TotalCount
    from #Main
    where RowNumber between (@PageIndex-1)*@PageSize+1 and @PageIndex*@PageSize 
    
End


sql语句
  select * from (
  select *,(select count(*) from t_approval_baseinfo) as TotalCount,Row_Number()over(order by reciev_time desc) as RowNumber
  from t_approval_baseinfo) rds
  where rds.RowNumber between (1-1)*10 +1 and 1*10

 

sql分页demo

标签:where   arch   use   div   name   ase   oval   weight   alt   

原文地址:http://www.cnblogs.com/sxxjyj/p/6398566.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!