Create Procedure PageTest - Test for page pages - need to put the sort field in the first column
(@Firstid nvarchar (20) = NULL, - The value of the sort field of the first record in the current page @Lastid nVarchar (20) = null, - the value of the last record in the current page @isnext Bit = null, --true 1: Next page; false 0: Previous @allcount int output, - Return to the total record number @PageSize Int output, - Return to a page Record @Curpage Int - Page Number (Partic "0: First page; -1 last page.)
AS
if @ CurPage = 0 begin - the total number of records statistical select @ allCount = count (ProductId) from Product_test set @ pageSize = 10 - return to the first page data select top 10 ProductId, ProductName, Introduction from Product_test order by ProductId end
Else if @ curpage = -1
Select * from (SELECT TOP 10 ProductID, ProductName, Introduction
From product_test Order by Productid Desc) AA Order by ProductIdELSE
begin if @ isNext = 1 - turn the page select top 10 ProductId, ProductName, Introduction from Product_test where ProductId> @LastID order by ProductId else - to previous page select * from (select top 10 ProductId, ProductName, Introduction from Product_Test Where ProductId <@firstid Order by Productid Desc) AS BB Order by ProductId End
Millions of data flips like 100 data!