Tags: SQL Server top Paging database pagingSQL Server Top Common scenarios: PagingSpecific usage:(1) Paging by IDSelect Top Page Size *From table1where ID not in (Select Top Page Size * (pages-1) ID from table1 ORDER by ID)Order by ID;(2) Pagination by dateSelect Top Page Size *From table1where ID not in (Select Top Pa
There are already many paging query methods, and I am also a member here.SQL Server has a Set Rowcount setting, which means that the command processing stops processing the command after responding to the specified number of rows, we can use it to implement high-performance paging query in a 10 million row-level data table. Let's talk about the implementation met
as--Set NOCOUNT on--Variable definition declare @TotalRecord intdeclare @TotalPage intdeclare @CurrentPageSize intdeclare @TotalRecordForPageIndex INTBEGIN IF @Where is NULL SET @Where =n "--Total records DECLARE @countSql NVARCHAR (4000) if @RecordCount is NU LL BEGIN SET @countSql = ' SELECT @TotalRecord =count (*) from ' [Email protected]+ ' [email protected] EXECUTEsp_executesql @countSql, N ' @TotalRecord int out ', @TotalRecord out END ELSE BEGIN SET @[email protected] END set @[email pro
The first type: Row_number () over () modeSELECT * FROM (SELECT *, Row_number () over (Order by ArtistID) as RowId from Artistmodels) as Bwhere RowId between and 20 ---where RowId between the current number of pages -1* and pages * Number of bars---The execution results are:The second way: offset fetch next mode (SQL2012 more than the version is supported: recommended)SELECT * from Artistmodels ORDER by ArtistID offset 4 rows fetch next 5 rows only--order by ArtistID offset page rows fetch Next
maximum ID value for the first 40 records.This query has one condition, that is, the ID must be of type int. The third method:Select Top 10 *From(Select Row_number () over (order by ID) as rownumber,* from test) Awhere RowNumber > 40Principle: First sort all the data in the table according to a rownumber, then query rownuber more than 40 of the first 10 recordsThis approach is similar to a paging method in Oracle, but only supports versions of 2005 o
ID value for the first 40 records.This query has one condition, that is, the ID must be of type int.The third method:Select Top 10 *From(Select Row_number () over (order by ID) as rownumber,* from test) Awhere RowNumber > 40Principle: First sort all the data in the table according to a rownumber, then query rownuber more than 40 of the first 10 recordsThis approach is similar to a paging method in Oracle, but only supports versions of 2005 or moreThe
Label: CREATE VIEW View_1--Create a new view name as--functions for building viewsSelectStudent.sno,sname,cno,degree fromStudent join score on student.sno=Score.sno GoSelect* fromView_1wheresno='1'
Select* from
(SelectStudent.sno,sname,cno,degree fromStudent join score on STUDENT.SNO=SCORE.SNO) asTable2 wheresno='101'--define as a temporary table with AS and then query the results from the table.
is also a sub-query, the subquery query out the result set, as a temporary table to use. --views ar
Bootstrap table server-side paging example, bootstraptable
1. You can download the js required for front-end introduction from the official website.
Function getTab (){Var url = contextPath + '/fundRetreatVoucher/fundBatchRetreatVoucherQuery.htm ';$ ('# Tab'). bootstrapTable ({Method: 'get', // set this parameter to get. I don't know why post cannot be obtained.Url: url,Cache: false,Height: 400,Striped: t
This article mainly introduces the bootstraptable server-side paging example sharing. For more information, see section 1. you can download the required js introduced at the front end from the official website.
The code is as follows:
Function getTab (){Var url = contextPath + '/fundRetreatVoucher/fundBatchRetreatVoucherQuery.htm ';$ ('# Tab'). bootstrapTable ({Method: 'GET', // set this parameter to get
This article mainly introduces the bootstraptable server-side paging example sharing. For more information, see section 1. You can download the required js introduced at the front end from the official website.
The Code is as follows:
Function getTab (){Var url = contextPath + '/fundRetreatVoucher/fundBatchRetreatVoucherQuery.htm ';$ ('# Tab'). bootstrapTable ({Method: 'get', // set this parameter to get
@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
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-
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.