|
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: - if exists(select * from sysObjects where name='存储过程名')
- drop proc 存储过程名
- go
- create procedure 存储过程名
- [
- 参数 数据类型[ = 默认值] [output],
- ……..
- ]
- as
- //语句块
- go
Copy code
|