Use SQL statements to make paging processing

xiaoxiao2021-03-06  40

/ * Use the SQL statement to make a page using this technology to multiply the number of the required pages with the page size, then order the results to be sorted by the top keyword, and then embed this query into another query. This query. It is the number of records of the size of the page size. Is descending processing This query is the last page that returns an embedded query. If needed, you can decrease in ascending order of the final query * /

Declare @PageSize Int - Document Document Declare @Pages INT - Sit @ PageSize = 3set @ Pages = 2Declare @SQL NVARCHAR (200) Set @ SQL = 'SELECT TOP' STR (@ PageSize) '* from (SELECT TOP' STR (@ Pagesize * @ Pages) '* from dbo.employees Order by Employeeid ASC) AS TORDER BY Employeeid Desc'Exec (@SQL)

转载请注明原文地址:https://www.9cbs.com/read-77945.html

New Post(0)