sql2005分页SQL

CREATE   PROCEDURE   [ dbo ] . [ GetUsers ]   -- 得到用户列表,注意这里的参数
     @RowIndex   int ,
    
@RecordCount   int
AS
BEGIN
    
SET  NOCOUNT  ON ;

    
With  VUsers  as  (
        
select   * ,row_number()  over  ( order   by  UserID  desc as  RowNum
        
from  MyUsers 
)

    
select   *   from  VUsers 
    
where  RowNum  >   @RowIndex   and  RowNum  <=  ( @RowIndex + @RecordCount )    
END

CREATE   PROCEDURE   [ dbo ] . [ GetUsersCount ]     
AS
BEGIN
    
SET  NOCOUNT  ON ;
    
select   count (UserID)  from  MyUsers
END

你可能感兴趣的:(sql2005)