Paging store procedure

zhaozj2021-02-16  145

/ * Name: Spall_deletenoneunique Enter: To query the table name and field list output: call: Description: Paging display of thousands of data! - You can get 100 records in 14.48 million records in 5 seconds. Do you? Author: Tekken-mail: Website: http: //www.wellknow.net Updated: 20,040,610 Support: http: //bbs.wellknow.net Copyright: quoted please indicate the source when: creating the future Wellknow.net with thinking * / CREATE Procedure getRecordfromPage @tblname varchar (255), - Table name @fldname varchar (255), - field name @PageSize INT = 10, - Page size @PageIndex INT = 1, - Typography @iscount bit = 0, - - Return to the total number of records, non-0 values ​​return @ORDERTYPE bit = 0, - Set the sort type, non-0 value is descended @Strwhere varchar (1000) = '- Query Conditions (Note: Do not add where) as declare @ STRSQL VARCHAR (6000) - Priority Declare @strtmp Varchar (100) - Temporary Variable Declare @strORDER VARCHAR (400) - Sort Type IF @OrDertype! = 0BEGIN SET @STRTMP = "<(SELECT MIN" set @strorder = "Order by [" @fldname "] desc" endelsebegin set @STRTRTMP = "> (Select Max" set @strorder = "Order by [" @fldname "] ASC" end set @strsql = "SELECT TOP " Str (@Pagesize) " * from [" @TBLNAME "] Where [" @fldname "] " @strtmp " ([" @fldname "]) from (SELECT TOP) " STR ((@ PageIndex-1) * @ PageSize) " [" @fldname "] from [" @TBLNAME "] " @strorder ") as tbltmp) @strorder if @Strwhere ! = '' Set @STRSQL = "SELECT TOP" STR (@

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

New Post(0)