存储过程分页

if object_id('tempdb.dbo.##P_Sys_getUserShellNew') is not null drop table ##P_Sys_getUserShellNew   ;
    declare @iStart int 
    declare @iEnd int 
    
    SET @iStart = (@PageIndex-1)*@PageSize+1                      
    SET @iEnd = (@PageIndex-1)*@PageSize+@PageSize 
    ;with #temp1 as(
         select ROW_NUMBER() over(order by regDate desc)  as ROWINDEX   ,shopsName from dbo.V_getUserShell
    )SELECT * INTO ##P_Sys_getUserShellNew FROM #temp1
    
     select * from ##P_Sys_getUserShellNew   where ROWINDEX  BETWEEN CAST(@iStart as varchar) AND CAST(@iEnd as varchar) 
     select count(*) from ##P_Sys_getUserShellNew

自己看的懂就行了  哈哈 做个笔记 因为经常忘记了,一直是复制粘贴

posted @ 2013-07-31 11:23  伤心木乃伊  阅读(178)  评论(0编辑  收藏  举报