1: Common SQL statements can be executed using Exec
Select * From tablenameExec ('select * From tablename ')Exec sp_executesql n 'select * From tablename' -- note that N must be added before the string.
2: when the field name, table name, database
/* Released Date: 2007-5-30ProcName: UP_GetRecordByPage */-- check UP_GetRecordByPageif exists (select * from dbo. sysobjects where id = object_id (n' [dbo]. [UP_GetRecordByPage] ') and OBJECTPROPERTY (id, n' IsProcedure') = 1) drop procedure [dbo].
Create procedure sp_pagination -- paging Stored Procedure (applicable when millions of pages have primary keys)(@ Fieldlist varchar (500), -- display the Field List@ Tablename varchar (50), -- query the table name@ ID varchar (50), -- Id field@
AJAX paging (content involves database stored procedures) and ajax stored procedures
First, we declare and define the stored procedure in the database (SQL Server ).
Use sales -- specify the database if (exists (select * from sys. objects where
This article only represents the understanding of the author at a certain stage.
I. Prerequisites for writing
Recently, a project uses LINQ to SQL, which provides applications for table, stored procedure, and function. For stored procedure, if
The primary key of the table must be the ID column. [ID] int identity () // you can add one at a time.
1. Paging solution 1: (use not in and select top pages)
Statement format:
CopyCode The Code is as follows: Select top 10 *
From testtable
Where
1. asp calls the Stored Procedure
First, create a database in SQL called it. I won't talk about how to create it. This is simple and I will know it at a glance. Create a table in the database and write several data records as follows:
Open the
Dynamic SQL
Bad:1. dynamic SQL is very dangerous, because dynamic SQL generally constructs your entire SQL statement based on user input, that is, we usually see some parameters involved in the SQL statement, average hackers will alsoUsing this
In the MSSQL Stored Procedure, table sharding is implemented to store table sharding queries and improve query efficiency.
Table sharding and table sharding for some fixed data can greatly improve the query performance. This is already accepted. The
Problem description:
In the dice game, a few steps forward in the map will be taken based on the number you throw. After the progress is completed, you need to perform corresponding operations based on the obstacles shown in the current map
Alter procedure [DBO]. [Page]@ TB varchar (20), -- table name@ Col varchar (100), -- pagination by this column@ Orderby bit, -- sort, 0-order, 1-inverted@ Collist varchar (1500), -- List of fields to be queried, * indicates all fields@ Pagesize int,
I. Differences between return and output in Stored Procedures
commonalities: All return values (but return can only return int type, output can be custom type, and then need to be defined as the variable of the stored procedure, such as @ out
ProgramCode Create procedure pagetest -- used for paging Testing
-- Put the sorting field in the first column
(
@ Firstid nvarchar (20) = NULL, -- the value of the sorting field of the first record on the current page
@ Lastid nvarchar (20) = NULL, -
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.