1.存储过程的分类
2.创建存储过程
?
1 2 3 4 5 6 7 | create procedure sp_goods_price
@minprice float ,@maxprice float
as
select * from goods
where price>=@minprice and price <=@maxprice
go
|
执行存储过程: execute sp_goods_price 200 2000
3.修改存储过程
?
1 2 3 4 5 6 | create procedure sp_goods_betw
@minprice float =200,@maxprice float =3000
as
select * from goods
where price>=@minprice and price <=@maxprice
go
|
4.删除存储过程
?
1 | drop procedure sp_goods_price
|
5.查看存储过程
?
1 2 | sp_helptext procedureName
sp_help procedureName
|
6.重命名存储过程
?
1 | exec sp_rename oldName newName
|
**局部存储过程
?
1 2 3 4 5 6 | create procedure #sp_goods_betw
@minprice float ,@maxprice float
as
select * from goods
where price>=@minprice and price <=@maxprice
go
|
**全局存储过程
?
1 2 3 4 5 6 | create procedure ##sp_goods_betw
@minprice float ,@maxprice float
as
select * from goods
where price>=@minprice and price <=@maxprice
go
|
**不加缓存的存储过程
?
1 2 3 4 5 6 7 | create procedure sp_goods_betw
@minprice float ,@maxprice float
with recompile
as
select * from goods
where price>=@minprice and price <=@maxprice
go
|
**加密存储过程
?
1 2 3 4 5 6 7 | create procedure sp_goods_betw
@minprice float ,@maxprice float
with enctyption
as
select * from goods
where price>=@minprice and price <=@maxprice
go
|
总结
以上所述是小编给大家介绍的Sql中存储过程的定义、修改和删除,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。