什么是存储过程? [英] WHAT IS STORED PROCEDURE ?
问题描述
15。什么是存储过程? SP的优点?
------------------------------------------ ----------------------------------------------
$ b $bA:存储过程是一组执行特定任务的结构化查询语言(SQL)语句。
•SP重复使用数据。它有助于重用代码。
•SP降低了代码背后代码的复杂性。
•SP增加了应用程序的安全性,它可以防止Sql注入和黑客入侵。
•代码维护和更改非常容易。如果需要更改,则不需要更改代码中的代码。
存储过程的语法:
创建 Proc Proc_Name
//声明变量
@ variable_name data_type = value
as
开始
// Body SP的class =code-keyword>。
结束
注意:。
1)改变程序你必须使用Alter
关键字替换Create
2)查看已存在于DB中的存储过程
Ex:
sp_helptext SP_Login
sp_login是存储过程名称
输出:
当你在查询编辑器中运行上面的代码时
u ll看到下面的输出
执行SP:
Exec Proc_Name参数
-------------- -------------------------------------------------- ---------------------------------------
http://cybarlab.blogspot.com/2012/12/stored- procedure-sp.html [ ^ ]
查看此链接
http://www.aspdotnet-suresh.com/2011/07/what-is-stored-procedure-in-sql-server .html [ ^ ]
http://en.wikipedia.org/ wiki / Stored_procedure [ ^ ]
http://searchsqlserver.techtarget.com/news/1052737/Why-use-存储-procedures [ ^ ]
http:/ /docs.synergyde.com/sql/sqlChap2Storedprocedures.html [ ^ ]
请通过此链接了解SP'。
存储过程是一组T-SQL语句,其中编写多个查询以获取输出。
存储过程有两种类型的参数。
a)输出类型参数
b)输入类型参数
SP可以通过参数返回一个或多个值,或者根本不返回。
SP可以返回多个值(最多1024个)。
我们可以在SP中使用插入,删除,更新和创建语句。
我们可以在存储过程中使用try catch语句
15. What is stored procedure? Advantages of SP?
----------------------------------------------------------------------------------------
A: Stored procedures are set of Structured Query Language (SQL) statements that perform particular task.
• SP have repeatedly using data. It helps to reuse the code.
• SP is reduces the complexity of code in code behind.
• SP increase the security to application, it protect from Sql injection and hacking.
• Code maintenance and changes are done very easily. Instead of changing the code in code behind if changes required.
Syntax of Stored procedure :
Create Proc Proc_Name
//declaring variables
@variable_name data_type =value
As
Begin
//Body of SP.
End
Note:.
1)To alter the procedure u have to use "Alter"
keyword with replace of "Create"
2) to view stored procedure already in DB
Ex:
sp_helptext SP_Login
sp_login is stored procedure name
out put :
when u run the above code in query editor
u ll see the below output
To Execute the SP:
Exec Proc_Name Parameters
-------------------------------------------------------------------------------------------------------
http://cybarlab.blogspot.com/2012/12/stored-procedure-sp.html[^]
Check with this links
http://www.aspdotnet-suresh.com/2011/07/what-is-stored-procedure-in-sql-server.html[^]
http://en.wikipedia.org/wiki/Stored_procedure[^]
http://searchsqlserver.techtarget.com/news/1052737/Why-use-stored-procedures[^]
http://docs.synergyde.com/sql/sqlChap2Storedprocedures.html[^]
please go through this links you have an idea about SP''s.
Stored Procedure is a set of T-SQL statements in which multiple queries are written to get the output.
Stored procedure have two types of parameters.
a) Output Type Parameter
b) Input Type Parameter
SP may return one or more values through parameters or may not return at all.
SP can return multiple values (max 1024).
We can use insert,delete,update and create statements in SP.
We can use try catch statements in stored procedures
这篇关于什么是存储过程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!