User register and confirm the online ASP program.
1. SQL table and storage process
---------------------------------------------
CREATE TABLE [dbo]. [Userbaseinfo] (
[UserID] [varchar] () not NULL,
[Password] [varchar] () not NULL,
[Validcodelogin] [
Stored Procedures | pagination | data
CREATE PROCEDURE Sp_page
@tb varchar (50),--table name
@col varchar (50),--Paging by this column
@coltype int,--type of @col column, 0-digit type, 1-character type, 2-date Time type
@orderby bit,--sort, 0-order,
CREATE PROCEDURE pagetest--a test for paging--You need to place the sort fields in the first column
(@FirstID nvarchar (=null)--the value of the sorted field for the first record in the current page@LastID nvarchar (=null)--the value of the sorted
Http://topic.csdn.net/u/20080421/15/b0e4c874-7c72-481d-8a95-37c2ce1f7d89.html
This stored procedure is performing well. 500W speed paging takes 2 seconds, any number of pages
But there is a problem is that if the sort is not a primary key, ID,
First look at the following code to create a stored procedure
1. Create a stored procedure with the following statement:
CREATE PROC p_viewpage @TableName VARCHAR (200),--table name @FieldList VARCHAR (2000),--Displays column name, if all
This is a recently written paging stored procedure that can be applied to SQL Server 2005:
Copy Code code as follows:
If object_id (' [Proc_selectforpager] ') is not null
Drop Procedure [Proc_selectforpager]
Go
Create Proc
paging function Stored ProceduresALTER PROCEDURE [dbo].[P_splitpagesquery]@TablesName NVARCHAR(MAX),--table name or view name (only flyer one table name)@PK NVARCHAR(MAX)="',--primary KEY (can be empty!) )@StrSort NVARCHAR(MAX)="',--sort fields
Execute believes everyone is using the cooked, abbreviated to exec, except for the execution of stored procedures, is generally used to perform dynamic SQLThe new system stored procedures introduced in sp_executesql,sql2005 are also used to handle
Classification of stored procedures(1) System stored procedureThe name of the system stored procedure usually begins with "sp_"Created, managed, and used by SQL Serverstored in the resource databaseMethods similar to those in the Java language class
SQL Server often uses a paging method to summarizeThe following demo sample summarizes that SQL Server database is frequently used for paging methods and is only for learning referencesA, using RowNumber and between and combination paging:/**********
Original: SQL Server monitors the number of commands that are not distributed in the publicationWe usually look at the number of commands that are not distributed.However, when the server has a lot of releases, it is troublesome to open the viewOf
A stored procedure is a set of T_SQL statements that accomplish a specific function, which is compiled and stored in the SQL Server service-side database to speed up the execution of SQL statements.7.1 create a stored procedureSyntax format:create
An existing full-Library query on the Web that does not recognize the database structure of a custom schema:Declare @str nvarchar(Ten)Declare @tablename varchar( -)Declare @colname varchar( -)Declare @counts intDeclare @sql nvarchar( -)--Define
* Ident_current returns the identity value that was last generated for any session and for a particular table in any scope.CREATE PROCEDURE [dbo]. [Pr_newsaffiche_addnewsentity] ( @NewsTitle varchar, @NewsContent varchar (4000), @Creator
CREATE PROC p_team_gettemalist @pageindex int, @pagesize int, @keywords VARCHAR (200),--fuzzy query name tag @cityco De VARCHAR, @verifyStatus int =0,---1 All 0 did not pass the 1 audit through @orderby int, @TotalCount int Outputas BEGIN
Q1: What is dynamic SQL ? A1: The first is the SQL statement, which is based on the conditions to stitch the SQLQ2: Why use dynamic SQL? A2: Because an OR occurs in a conditional where , the index is not used, resulting in a significant difference
Copy codeThe Code is as follows:-- Based on MAX (MIN) IDCreate proc [dbo]. [proc_select_id]@ Pageindex int = 1, -- current page number@ Pagesize int = 10, -- size of each page@ Tablename VARCHAR (50) = '', -- table name@ Fields VARCHAR (1000) = '', -
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.