server| Stored Procedures | paging
Killergo's Column
Recently, because of a bit of free time, I thought about how to use the paging of stored procedures on the SQL Server platform, now listed below.
In the actual test, the performance of the two is
Temporary tables I'm having a lot of trouble debugging the following stored procedures (mostly temporary table operations):
CREATE PROCEDURE [C_readtop] @eachrow int=10 as
DECLARE @tmpcat varchar (16)
CREATE TABLE #tmp_result (arid int,cat2 varchar)
variables | stored Procedures | Pagination to create a stored procedure that returns the results of a specified record, you must first specify the number of records to return the result set, either with a temporary table or with a table variable
Select
Select returns the order of records
Zhongxing Communication Chongqing Institute Rempo Wu Yuhong
Keywords: SELECT, order, optimize, backup, scan, index
Article Summary:
When we execute the SELECT statement, the order of the records
Suppose you have a table of people (table name: person), if you want to name, ID number, address the three fields exactly the same records to find out, using
1: SELECT p1.*
2: From persons p1,persons p2
3: WHERE
The MSDN docs contain the list of T-SQL that are either partially supported or not supported. For example see the following location for CREATE table-http://msdn.microsoft.com/en-us/library/ee336258.aspxIn Elmah's case, the filegroup are not
[Reprint: Http://www.3lian.com/edu/2013/12-30/120014.html]1. Upgrading hardware2, according to the query criteria, index, optimize the index, optimize access mode, limit the data volume of the result set.3, expand the memory of the server4. Increase
First, create a stored procedureIf Exists (select name from sysobjects where name = ' Sp1loginuser ' and type= ' P ')drop procedure Sp1loginuserGOCREATE PROCEDURE [dbo]. [Sp1loginuser]--Add The parameters for the stored procedure here@username
Killergo's Column
Recently, because of a bit of free time, I thought about how to use the paging of stored procedures on the SQL Server platform, now listed below.
In the actual test, the performance of the two is roughly equal in the case of 15,000
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
First, get the total number of rows in the data
Copy Code code as follows:
Set ANSI_NULLS on
SET QUOTED_IDENTIFIER ON
Go
ALTER PROCEDURE [Sq8reyoung]. [Fenye_num]
(
@TableNames NVARCHAR (200),
@Filter nvarchar (200))
As
Method One
Copy Code code as follows:
Declare @max integer, @id integer
Declare cur_rows cursor Local for select main field, COUNT (*) from table name Group by main field having count (*) > 1
Open Cur_rows
Fetch cur_rows into @
The article has a collection of two SQL paging stored procedure Code, these two stored procedures are two efficient paging stored procedure Code, if you think you write the statement is not enough, strong, you can use our ready-made efficient paging
For example:ID Name Value1 a pp2 a PP3 B III4 B pp5 B pp6 C pp7 C pp8 C IIIID is primary keyAsk for such a resultID Name Value1 a pp3 B III4 B pp6 C pp8 C III
Method 1
Copy Code code as follows:
Delete yourtable
where [id] not in (
SQL statements for querying and deleting duplicate records1, look for redundant records in the table, duplicate records are based on a single field (ID) to judgeSELECT * FROM table where ID in (select Id from table GROUP by ID have count (Id) > 1)
Method One
Declare @max integer, @id integer
Declare cur_rows cursor Local for select main field, COUNT (*) from table name Group by main field having count (*) > 1
Open Cur_rows
Fetch cur_rows into @id, @max
While @ @fetch_status
XML is the latest solution for data storage. XML gives web developers greater programming flexibility than HTML. This technology-driven development organization tries to integrate XML with its own products. Microsoft is the pioneer of such a move.
Ways to query and delete duplicate recordsA1, look for redundant records in the table, duplicate records are based on a single field (Peopleid) to determineSELECT * from Peoplewhere Peopleid in (select Peopleid from People GROUP by Peopleid have
SQL statement for querying and deleting duplicate records 1, look for redundant records in the table, duplicate records are based on a single field (Peopleid) to determineSELECT * from Peoplewhere Peopleid in (select Peopleid from People GROUP by
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.