This article is a mirror article of machine translation, please click here to jump to the original article.

View: 13932|Reply: 0

[Source] Detailed explanation of sqlserver creating stored procedures

[Copy link]
Posted on 10/9/2014 9:59:34 AM | | |
1. Stored Procedure: Similar to a method in C#, it is a collection of SQL statements to complete a specific task.
Features: Used to manage or handle more complex business logic. There can be parameters, return values, and parameters with return values, where variables can be defined and process control statements can be written. Create database statement cannot be included
Advantages: Improved reusability, allows for modular design, increased execution speed, reduced network traffic, and improved security.
Categories:
       1. System storage process:
1) System definition, existing in master
2) It usually starts with a sp_ or xp_.
              sp_ used to set system parameters
              xp_ used to invoke functions provided by the operating system
              Call the system stored procedure: execute the stored procedure name
       2. Customize the storage procedure
              1) User-defined, existing in the current database.
              2) Usually starts with p_. (The name is customized)
'Create syntax:
  1. if exists(select * from  sysObjects where name='存储过程名')
  2. drop proc 存储过程名
  3. go
  4. create  procedure  存储过程名
  5. [
  6. 参数 数据类型[ = 默认值] [output],
  7. ……..
  8. ]
  9. as
  10.   //语句块
  11. go
Copy code






Previous:Call the stored procedure of the database in C#
Next:Why use stored procedures in sql, and what are the advantages?
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com