For database data in the UI interface pagination is a cliché question, the Internet is easy to find a variety of "common stored Procedures" code, and some also customized query conditions, it looks very convenient to use. I intend to use this article to briefly discuss the paging stored procedure based on SQL Server 2000, while talking about the evolution of the paging
server|sqlserver| Stored Procedures | paging
/*--displays the specified table using a paging program implemented by the stored procedure, view, page X of query results for the primary key or identity column in the table, fetch the query directly from the original table, otherwise use the temporary table method if there are primary keys in the view or query result
Label:--sql Paging stored procedure [email protected] query statement [email protected] current page [email protected] Number of messages per page--return value---1, number of records---2, qualifying recordset CREATE proc Edure pagingquery @sqlstr nvarchar (4000),--query string @currentpage int,--page n @pagesize int,--Number of rows per page @allrecords int OUTPUT-- The total number of records returned as SET NOCOUNT on declare @P1 int,--P1 is the ID
/// ///use virtual tables for paged queries that do not apply to queries that explicitly know the column name/// /// SQL such as "SELECT * from name where 1=1"/// page number such as "1"/// the number of bars, such as "/// DataTable Public StaticDataTable selectpaging (String sql,intPageIndex,intpageSize) { //Defining virtual table names stringTemporarytable ="#"+randstring (); //Create your virtual tables stringSqlpaging ="Select Identity (int) as ZZZZZ, * into"+ temporarytable +"From
Label:1.not in method select top from books where ID not in (select top with ID from books) 2.row_number () function select * FROM (select *,ro W_number () over (order by ID) Numfrom books) a where num between and 40 3. Stored procedure paging create proc Proc_adminpages@pageindex i NT,--Current page @pagesize int--number per page asdeclare @begin int, @end int--define local variable set @[email protected]* (@pageIndex-1) +1--assignment set @[ Email p
Tags: style blog color ar sp div c onHere is the creation of the stored procedure, which is called when it is used./** * * * object:storedprocedure [dbo]. [Sq_paging] Script date:09/10/2014 09:57:54 * * * * **/SETAnsi_nulls onGOSETQuoted_identifier onGOCREATE proc [dbo].[Yc_pageselect]@tbName varchar(255),--Table name@tbFields varchar( +),--return field@PageSize int,--Page Size@PageIndex int,--Page Number@strWhere varchar( +),--Query Criteria@StrOrder varchar(255),--Sorting Criteria@Key varchar(
Label: if object_id('[Proc_selectforpager]') is not NULL
Drop Procedure [Proc_selectforpager]
Go
Create ProcProc_selectforpager (@Tb_name varchar(Max) ,--Table name
@Order varchar(4000) ,--Sort Fields
@CurrentPage int,--Current Page
@Field varchar( -),--query Fields
@PageSize int,--shows the number of records per page
@TotalCount intoutput) as
Declare @Exec_sql nvarchar(Max)
/*total number of records queried*/
Set @Exec_sql='Set @TotalCount = (Select Count (1) fr
SQL SERVER Universal Paging stored proceduresStarting with SQL Server 2005, provided the Row_number () function, using the function generated by the index to handle paging, according to normal logical thinking is to pass pageindex and pagesize to complete the paging, the fro
Objective
In the previous section we talked about data types and a few things to note in the string, and we went on to talk about string lines as well as other content and interspersed content, short content, in-depth explanation. (Refer to the article "detailed SQL Server data type")
Paging Way
In SQL 2005 or SQL 2008 we use the Row_number open window function for p
SQL Server database paging query has been a short board of SQL Server, idle, come up with several methods, assuming that there are table article, Field ID, year ... (other omitted), Data 53,210 (customer real data, quantity is not large), paging query each page 30, query page 1500th (ie 第45001-45030条 data), field ID cl
server|sqlserver| Paging
There are three ways to pagination with SQL and Oracle databases!
Let's take a look at how the two methods are implemented if we want to get data from 1000th to 1010th in the database.
1. Methods of using temporary tables. (The main thing in the system is to write SQL statements directly)
A) Arrange the order by the order you want
b) Create a temporary table
c The
SQL Server database paging query has been SQL Server's short board, assuming that there is a table article, field ID, year, data 53,210 (customer real data, the amount of small), paged query every page 30, Query page 1500th (i.e. 第45001-45030条 data), field ID clustered index, Year no index, SQL Server version: 2008R2The first scenario:Select top article WHERE ID
Label:SQL Server database paging query has been SQL Server's short board, Idle to do nothing, think of several methods, assuming that there is a table article, Field ID, year ... (other omitted), Data 53,210 (customer real data, amount of small), page 30 per page, query page 1500th (that is, 第45001-45030条 data), field ID clustered index, Year no index, SQL Server
ThinkPHP integrates datatables to implement sample code for server paging, thinkphpdatatables
There is a demand for doing something recently, because the data volume is large, here I decided to use the Ables Server Page, and also need to pass the query conditions to the server. Most of the articles searched on the Inte
Atitit. Mssql SQL server converts mysql and paging SQL ast, atitit. mssqlast
Atitit. Mssql SQL server converts mysql and sets up paging SQL ast
1. Major conversions: Function Conversion, paging conversion 1
2. Idea: mssql SQL> ast> mysql 1
3. SQL mainly includes: 1
4. Mssql
Solutions for querying paging data using SQL Server SQL statements:
You must select 3,000th records on page 1 of tbllendlist, with 100 records on each page. -------------------------
----------Method 1:----------Select Top 100 * From tbllendlistWhere fldserialno not in(Select top 300100 fldserialno from tbllendlistOrder by fldserialno)Order by fldserialno
----------Method 2:----------Select Top 100 *F
Label:Atitit. MSSQL SQL Server conversion MySQL and paging SQL AST build1. Main conversions :: function Conversion , paging conversion 12. Ideas :: MSSQL SQL >>ast>>mysql 13. the main SQL is as follows ::: 14. Mssql2mysqlconvertor (proj:wechatadm4propt 21. The main conversion::Conversion of Functions,Paging Conversio
Paging SQL Server stored procedure
Paging SQL Server stored procedure
/* -- Paging program implemented by stored procedures
Displays page X of the specified table, view, and query result.
In the case of primary keys or ID columns in the table, query the data directly from t
Before SQL Server 2012, the implementation of paging was primarily using row_number (), in SQL Server2012, you can use the offset ... Rows Fetch Next ... Rows only way to implement paging data query.Select [Column1] ,[Column2] ... ,[ColumnN] from [TableName]Order by [COLUMNM]offset (PageIndex-1)*pageSize rowsFetch NextPageSize rows onlyin the
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.