Many friends who start learning programming will encounter problems with a non-data paging store when using the database custom paging.
Here I offer a few database-based stored procedures for their own experiences and learning experiences and share it.
1. Use TOP1.1 to use the current record number (CurrentNote) and Paging Page Size (PageSize)
Create Proc getNextPageInfo2
@PageSize Int, --Page Size
@CurrentNote Int --Current Note
AS
Declare @sql nvarchar (200)
Set @ SQL = N'SELECT TOP ' Convert (VARCHAR (10), @ Pagesize)
'* from dbo.userinfo where userid> convert (varchar (10), @ currentnote)
EXEC SP_EXECUTESQL @SQL
Go
1.2 Page with this page and paged page size
Create Proc getNextPageInfo
@PageSize Int, --Page Size
@Page Int --CurrentPage NO
AS
Declare @Jilu Bigint
Set @jilu = (@ PageSize * @ PAGE)
Declare @sql nvarchar (200)
Set @ SQL = N'SELECT TOP ' Convert (VARCHAR (10), @ Pagesize)
'* from dbo.userinfo where userid not in (SELECT TOP' Convert (varchar (10), @ jilu)
'userid from userinfo order by userid) Order by userid'
EXEC SP_EXECUTESQL @SQL
Go
Two ways compare: The first execution efficiency should be higher than the second, but the second method is relatively simple in the case where the ID number is changed.
2, use rowcount
3, 2.1 Using the current record number (CurrentNote) and Paging Page Size (PageSize)
Create Proc getNextPageInfo3
@PageSize Int, ---- Page Size
@CurrentNote Int ---- The last record number of the current page
AS
Set rowcount @PageSize
Select * from userinfo where userid> @currentnote
Of course, there are many other methods in addition to several other than the above. I hope that everyone can communicate more in the process of learning, and everyone will make progress together.