declare @PageSize int --页面大小,如每页存储20条记录
,@PageIndex int --当前页码,从1开始
set @PageSize=200
set @PageIndex=3
declare @Indextable table(
aid int identity(1,1)
,BillNo nvarchar(20)
) --定义表变量
declare @PageLowerBound int --定义此页的底码
declare @PageUpperBound int --定义此页的顶码
set @PageLowerBound=(@PageIndex-1)*@PageSize
set @PageUpperBound=@PageLowerBound+@PageSize
set rowcount @PageUpperBound
insert into @Indextable(BillNo)
select BillNo from PD01_Product
--where fariqi >dateadd(day,-365,getdate())
order by BillNo
select BillNo,ProductNo,ProductName,Specification,Unit,Memo
From PD01_Product
where State<100 and BillNo in (select BillNo from @Indextable where aid>@PageLowerBound and aid<=@PageUpperBound)
|