The way to write a stored procedure is: 1. Create a stored procedure, the code is [create proc sp_name]; 2. Call the stored procedure, the code is [exec sp_name [parameter name]].
The operating environment of this article: Windows 7 system, Microsoft Visual C 2015 version, Dell G3 computer.
The stored procedure writing method is:
1. Create a stored procedure
create procedure sp_name @[参数名] [类型],@[参数名] [类型] as begin ......... end 以上格式还可以简写成: create proc sp_name @[参数名] [类型],@[参数名] [类型] as begin ......... end /*注:“sp_name”为需要创建的存储过程的名字,该名字不可以以阿拉伯数字开头*/
2. Call the stored procedure
Stored procedures can be called in three environments:
Under the command command, the basic syntax is: exec sp_name [parameter name]
;
In SQL environment, the basic syntax is: call sp_name [parameter name]
;
PL/SQL Environment, the basic syntax is: begin sp_name [parameter name] end
;
##3. Delete the stored procedure
1. Basic syntax:drop procedure sp_name
4. Other commonly used commands
1.show procedure status
show create procedure sp_name
exec sp_helptext sp_name
sp_nameobject creation text
Programming Teaching! !
The above is the detailed content of How to write stored procedure. For more information, please follow other related articles on the PHP Chinese website!