The first one supports a unique primary key, and the second one supports multiple primary keys, which have been tested and are efficient.
Create proc p_viewpage/*No_miss paging Stored Procedure 2007.2.20 QQ: 34813284Applicable to tables or views
The paging stored procedures are roughly the following
1. Use not in and select top
2. Use ID greater than number and select top
3, using the cursor in SQL
4. Temporary table
You can see the following links on the web
Summary of common paging
first, the basic concept
The SQL Server database engine ignores the commit of the internal transaction. The internal transaction is committed or rolled back according to the action taken at the end of the most external transaction. If an external
Website comment information is the most resource-consuming part. Optimizing comment data is crucial for large websites. No SETANSI_NULLSONGOSETQUOTED_IDENTIFIERONGOCREATETABLE [dbo]. [CommentsTables] ([ID] [int] IDENTITY (1, 1) NOTNULL, [Key]
Example 1. Used for paging of common data The code is as follows:Copy code Create procedure [dbo]. [Pub_DataPager]@ PTableName nvarchar (1000), -- table name@ PFieldNames nvarchar (max), -- string to be queried, separated by ",", or '*'@ PWhere
During device control, it is troublesome to display the signal of devices connected to the matrix output end (such as projectors and monitors,
The method I used is as follows:
First, create an interface:
Code highlighting produced by Actipro
I. Problems Encountered
We have written a lot of batch processing statements in our previous courses. These batch processing statements have two problems:
1. Unable to pass parameters like functions (custom)
2. It cannot be called repeatedly like a
Recently wrote a large piece of code, the abstract is very strong, easy to go around, because the cost of writing a single test is very large (excuse), so many problems to the joint is not found.And it took a lot of experience to find out, the main
The code is as follows
Copy Code
Create PROC P_viewpage/**//*Nzperfect [No_miss] Efficient common paging stored procedure (bidirectional retrieval) 2007.5.7 qq:34813284Warning: Tables or views that apply to a single primary key or
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
Yuanwen:http://www.jb51.net/article/35212.htmSQL 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
The article found two efficient paging codes for the mssqlserver stored procedure. If you need them, please refer to them.
The article found two efficient paging codes for mssql server Stored Procedures. If you need them, please refer to them.
SQL Server database paging query has always been a short board of SQL Server, so I have nothing to worry about. I have come up with several methods, for example, table ARTICLE, field ID, YEAR... (others omitted). There are 53210 million pieces of
The first solution, the simplest and common method:
Copy codeThe Code is as follows:Select top 30 * from article where id not in (select top 45000 id from article order by year desc, id desc) order by year desc, ID DESC
Average query time: 45
Detailed parameter descriptions are provided for the paging Stored Procedure of SQL2000.
Detailed parameter descriptions for paging stored procedures in SQL 2000
The Code is as follows:
----------------------------------------------------
-- Paging
Create PROCEDURE Sp_Conn_Sort(@ TblName varchar (255), -- table name
@ StrGetFields varchar (1000) = '*', -- the column to be returned
@ FldName varchar (255) = '', -- Name of the sorted Field
@ PageSize int = 40, -- page size
@ PageIndex int = 1, --
Http://www.594jsh.cn/Look.asp? Id = 75
Create proc p_viewpage_a/*Nzperfect [no_miss] efficient and common paging Stored Procedure (bidirectional retrieval) 2007.5.7 QQ: 34813284Tip: Applicable to tables or views with a single primary key or a
Paging is very important and will be encountered during the interview. Let's review and summarize it.
1. Create a test environment (it takes about 5 minutes to insert 1 million data records ).
Create Database dbtest Use dbtest -- Create a test
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.