Paging program implemented with stored procedures

xiaoxiao2021-03-05  25

/ * Paging program implemented with stored procedures * / create proc sp_pageRecordset @querystr nvarchar (1000), - Query statement, do not add "SELECT" or "Top N" @keyfield nvarchar (200), - Identification field @ PageSize Int, - Row of per page @PAGENUMBER INT - Page number to display, start from 0 as begin Declare @sqltext as nvarchar (4000) Declare @sqltable as nvarchar (4000) set @sqltable = 'SELECT TOP' CAST ((@ PAGENUMBER 1) * @PageSize As Varchar (30)) '' @querystr set @sqltext = 'SELECT TOP' CAST (@Pagesize As Varchar (30)) '*' 'from ' @sqltable ') As Tablea ' ' Where ' @keyfield ' Not in (SELECT TOP ' CAST (@PAGENUMBER * @PageSize As Varchar (30)) ' ' @keyfield ' from (' @SqlTable ') as Tableb)' Exec (@sqltext) end test -------------------------------------------------------------------------------------------------------------------------- -------------------------- Drop Procedure SP_PageRecordset Exec Sp_pageRecordset @queryStr = '* from Wzta ORDER BY [Id], @keyfield =' [ ID] ', @PageSize = 100, @PAGenumber = 6000

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

New Post(0)