Suitable for most of the stored procedure paging, I personally think it is good, more common, but not sorting, statistics, collection -------- p_splitpage
Alter procedure [DBO]. [p_splitpage]
@ SQL varchar (8000), -- SQL statement to be executed
@ Page Int = 1, -- the page number to be displayed
@ Pagesize int, -- size of each page
@ Pagecount Int = 0 out, -- total number of pages
@ Recordcount Int = 0 out -- total number of records
As
Begin
Set nocount on
Declare @ P1 int
Exec sp_cursoropen @ P1 output, @ SQL, @ scrolopt = 1, @ ccopt = 1, @ rowcount = @ pagecount output
Set @ recordcount = @ pagecount
Select @ pagecount = ceiling (1.0 * @ pagecount/@ pagesize), @ page = (@ page-1) * @ pagesize + 1
Exec sp_cursorfetch @ P1, 16, @ page, @ pagesize
Exec sp_cursorclose @ p1
Select @ pagecount, @ recordcount
End
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service