Some experiences on the writing of stored procedures _mssql

Source: Internet
Author: User
Because of the knowledge of the JS of Zhou Niu, I will share the initial stage of writing the storage process under SQL
In the database world, in the SQL,DB, Oracle three databases, by writing a storage process to enhance or change the function of the business is a means, the increased flexibility of the database is self-evident. Let me introduce the writing of the stored procedure below.
The essence of a database stored procedure is a set of defined code and SQL that is deployed on the database side:
Let's take a look at our paging storage instance:
For example, the contents of the table car are as follows
Numbered title price
001 BMW $30000
002 BENZ $31000

Instance 1: Stored procedures for querying the contents of a table car
Copy Code code as follows:

Create proc Baidu_car
As
SELECT * FROM car
Go
EXEC Baidu_car

Example 2: Add a record to the table car
Copy Code code as follows:

Create proc Insert_car
@param1 Char, @param2 varchar, @param3 money
With encryption---------encryption
As
Insert car (number, name, price) Values (@param1, @param2, @param3)
Go
Example of execution:
exec insert_car ' 008 ', ' Lamborghiri ', 100000
Go

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.