@timediff datetimebeginsetnocounton;select@timediff=getdate()selectNBSP; * NBSP; from NBSP; ( Select NBSP; *,row_number () over (order NBSP; by NBSP; ID ASC NBSP; as Idrank NBSP; from NBSP; tb_ testtable) NBSP; as idwithrownumber NBSP; where idrank> @pageSize * @pageIndex and idrank selectdatediff(ms,@timediff,getdate())as耗时setnocount off;end---5、利用临时表及Row_numbercreate procedure proc_CTE --利用临时表及Row_number(@pageIndexint, --页索引@pageSizeint--页记录数)assetnocounto
SQL Server Paging templatesWith TAs(SELECT Row_number ()Over (ORDERby albumID)As Row_number,*From (SELECT Albumid,title,genreid,artistid,price,albumarturlFrom albumsWHERE1=1and Genreid=@GenreId)AsASELECT*From Twhere row_number > @ Startrownum and row_number @EndRowNum select count (1) from (select Albumid,title,genreid,artistid,price , Albumarturl from albums where 1=1 and genreid = @GenreId) as B
Tags: using data SP C size r database SQL BSPaged query statements that are used in different databases:Current page: CurrentPagePage Size: pagesize1. Oracle DatabaseSELECT * FROM (select A.*,rownum rn from (query_sql) A) where Rn Note: query_sql is a query SQL statement.OrSELECT * FROM (select RowNum rn,id from TABLENAME where RowNum 2. Infomix DatabaseSelect Skip CurrentPage First pagesize * from TABLENAME3. DB2 DatabaseSELECT * FROM (select field 1, Field 2, Field 3,rownumber () over (order b
Method 1:Applies to SQL Server 2000/2005SELECT TOP Page Size *From table1WHERE ID not in ( SELECT TOP Page Size * (pages-1) ID from table1 ORDER by ID )ORDER by IDMethod 2:Applies to SQL Server 2000/2005SELECT TOP Page Size *From table1WHERE ID > ( ( SELECT TOP Page Size * (pages-1) ID from table1 ORDER by ID
SQL Server paging query stored procedures used in the project.
Stored Procedure]
Create PROCEDURE prcPageResult-- Get data on a page --
@ CurrPage int = 1, -- current page number (that is, Top currPage)
@ ShowColumn varchar (2000) = '*', -- the expected field (column1, column2 ,......)
@ StrCondition varchar (2000) = '', -- the query condition (where condition...) does not need to be added with the where ke
Also, SQL Server paging Query
Currently, the following two methods are commonly used:
1. Select top @ pagesize * From Table1 where id not in (select top @ pagesize * (@ page-1) ID from Table1 order by ID) order by ID
2. Select * from (select top @ pagesize * @ page * From Table1 order by ID) A order by id desc) B order by ID
Which method is better? I tried it.
Make two tables, each with 10 thousand rec
1, the front desk to introduce the required JS can be downloaded from the official web
Copy Code code as follows:
function Gettab () {
var url = contextpath+ '/fundretreatvoucher/fundbatchretreatvoucherquery.htm ';
$ (' #tab '). Bootstraptable ({
Method: ' Getting ',//here to set to get, do not know why the set post can not be
Url:url,
Cache:false,
height:400,
Striped:true,
Pagination:true,
PageList: [10,20],
ContentType: "Application/x-www-form-urlencoded",
Pagesize:10,
1. SQL Server, Access database
This is all Microsoft's database, is a family, the basic operation is similar, often using the following paging statement:
PAGESIZE: Number of records displayed per page
CurrentPage: Current page number
The name of the datasheet is: components
Index PRIMARY key word is: ID
以下是引用片段: select top PAGESIZE * from components where id not in (select top (PAGESIZE*(CURRENTPAGE-
server| Paging
Now generally used in the following 2 ways:
1. Select Top @pagesize * "from table1 where id" (SELECT top @pagesize * (@page-1) ID to table1 order by ID by ID
2. Select * FROM (select top @pagesize * to (select top @pagesize * @page * FROM table1 ORDER BY id DESC) b Order by ID
Which method is better? Try it.
Do two table, each has 10,000 records, a table ID has index, one does not
F
PublicIlistintPageSize,intPageIndex, out intTotalitemcount) { varTotalsql ="SELECT COUNT (1) from UserInfo"; Object result=getscalar (Totalsql); Totalitemcount= result = =NULL?0: Converthandler.toint32 (Result); varsql =string. Format (@"Select U2.N, u.* from UserInfo U, (select TOP {0} row_number () Over (ORDER by Name DESC) N, CODE from UserInfo) u2 WHERE U.code = U2. CODE and U2.N >= {1} ORDER by U2.N ASC", ((@pageIndex-1) * @pageSize) + @pageSize, ((@pageIndex-1) * @pageSize) +1); returnG
Tags: sort a table without bit BER 9.png CAS-Pre A little bit of the online circulation of the general change, even the results of the table query can be returned Create PROC [dbo]. [PageView]
(
@sql nvarchar (max),---The original query statement
@PageIndex int,--page number
@PageSize int,--Number of records per page
@Sort VARCHAR (255),-- Sort fields and rules without adding an order by
@GetCount bit--whether the total number of records is 1 for the total number of records, 0 for the total nu
1 Use [Database name]2 GO3 4 SETAnsi_nulls on5 GO6 7 SETQuoted_identifier on8 GO9 CREATE PROCEDURE [dbo].[Stored Procedure name]Ten @pageIndex INT, One @pageSize INT, A @totalCount INTOUTPUT - as - SETNOCOUNT on the - DECLARE @PageStart INT - DECLARE @PageEnd INT - + SET @pageStart=(@pageIndex-1)*@pageSize - SET @pageEnd=@pageIndex*@pageSize + BEGIN A SELECT @totalCount=COUNT(1) from [dbo].[Table name] at SELECT - [Id] - , Field 1 - , Field 2 - ,
),--The table name @strGetFields varchar (1000) = ' * ',--the column that needs to be returned @fldName varchar (255) = ',--the field name of the sort @PageSize int = 10,--page dimension @PageIndex int = 1,--page number @OrderType bit = 0,--set sort type, non 0 value descending @strWhere varchar (1500) = ',--query condition (Note: Do not add where) @Counts int = 0 OUTPUT--the number of records queried) as declare @strSQL nvarchar (4000)--The subject sentence declare @strTmp nvarchar (110) --Temp
Label:Writing:Pretend to have a table shop, which has a list of shopname, taking 100000 to 100,050 data. The writing of Row_number SELECT * from
(SELECT Over (ORDER by Shopname) as R
from Shop ) T
WHERE R>100000 and R100050 The writing of Offset,fetch SELECT from Shop
ORDER by Shopname
OFFSET 100000 ROW
FETCHNEXT Comparison:The difference in execution time can be clearly seen when 100,000 data are taken. Although the previous people have given a lot of arguments, I will stick to th
Use [Reportservertempdb]gocreate PROCEDURE [dbo]. [Seachtablepage] (@TableName varchar,--table name @fileds varchar,--query field @orderfiled varchar,--sort field @isdesc BIT,-- Whether to sort in descending order @wherestring VARCHAR (2000),--query field @pageindex int,--current page @pagesize int,--number of bars per page @totalrecord int output--return total number of bars) ASBE Gindeclare @OrderString VARCHAR (@PageIndex is NULL OR @PageIndex SQL Server
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.