SQL Server A relatively good paging stored procedure P_splitpage

Source: Internet
Author: User
CREATE procedure P_splitpage@sql nvarchar (4000),--The SQL statement to execute @page int=1,    --the page number to display @pagesize int,  -- Size per page @pagecount int=0 out,--total number of pages @recordcount int=0 out--Total records asset nocount Ondeclare @p1 intexec sp_cursoropen @p1 output, @sql, @scrollopt =1, @ccopt =1,@[email protected] outputset @recordCount = @pageCountselect @pagecount =ceiling (1.0*@ pagecount/@pagesize), @page = (@page-1) * @pagesize +1exec sp_cursorfetch @p1, @page, @pagesizeexec sp_cursorclose @ P1go



SQL Server A relatively good paging stored procedure P_splitpage

Related Article

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.