use master
go
set nocount on
go
set showplan_text on
go
--2012的OFFSET分页方式
select number
from spt_values
where type='p'
order by number offset 10 rows fetch next 5 rows only;
go
IF(@PageNo<1)
BEGIN
SET @PageNo=1
END
SELECT * FROM [ZhongNanMDS_Middle].[dbo].[MT_Plan_Node]
WHERE 1=1
AND (@ProjectCode IS NULL OR @ProjectCode='' OR ProjectCode= @ProjectCode)
AND (@PhaseCode IS NULL OR @PhaseCode='' OR PLAN_TEAM_ID= @PhaseCode)
AND (@beginTimeStamp IS NULL OR SyncTime>@beginTimeStamp)
ORDER BY SyncTime OFFSET (@PageNo-1)*@PageNum ROWS FETCH NEXT @PageNum ROWS ONLY;
--2005的ROW_NUMBER分页方式
select number from (
select number,row_number() over(order by number) as num from spt_values where type='p'
) t where num between 11 and 15
order by number asc
go
--2000的TOP分页方式
select number from (
select top 5 number from (
select top 15 number from spt_values where type='p' order by number asc
) t
order by number desc
) t
order by number asc
go
set showplan_text off
go