--☆★--***存储过程proc***--★☆--(重要):
==========与C#中的函数(方法)一样。存储过程 有名,可以有参数、返回值
优点:
(1)执行速度更快--
(2)允许模块化的程序设计--类似方法的复用
(3)提高系统的安全性--防止sql注入
(4)减少网络流通量--只要传输 存储过程名称
一、系统存储过程
放在系统数据库master中--可编程性--存储过程--系统存储过程中
☆==执行存储过程
exec sp_databases
事物ACID特性
A:原子性 C:一致性 I:隔离性 D:持久性
==1.没有参数的存储过程
--创建存储过程
create proc usp_Helloworld
as
begin
print 'Hello world!'
end
--使用存储过程
exec usp_Helloworld
===2.带参数的存储过程
create proc usp_AddTwo
@number1 int,
@number2 int
as
begin
print @number1+@number2
end
方法一{
declare @a int=20
declare @b int=40
exec usp_AddTwo @a,@b}
方法二:
exec usp_AddTwo 20,40 输出60