Jimmypony的技术汇总区
很多都不会,很多都不懂,不要浮躁,静心学习

1 使用Row_Number

with t_pager as (select myIndex = ROW_NUMBER() OVER (ORDER BY TableColumns),* from class where)
select * from t_pager where myIndex between StartIndex and EndIndex
 
 
2 使用表变量
declare @tt table(id int identity(1,1),nid int)
insert into @tt(nid) 
select top EndIndex class_id from class

select a.* from class a,@tt b where a.class_id=b.nid
and b.id between StartIndex and EndIndex order by b.id
 

 3 TopInTop

select top PageNums * from class 
    
where Table_id in (
        
select top EndIndex Table_id from class
        
order by Table_id desc
    ) 
    
order by Table_id
posted on 2008-08-04 14:28  Jim~  阅读(212)  评论(0编辑  收藏  举报