SQL SERVER 存储过程语法


判断是否存在的存储过程

if (OBJECT_ID('存储过程名称'),'P') is not null
drop procedure 存储过程名称
go
或者
if OBJECT_ID('存储过程名称) is not null
drop procedure 存储过程名称
go

--不带默认值存储过程语法
--创建语法  
create proc / procedure   存储过程名称

--参数

@参数名称  参数类型   

as

自定义sql业务逻辑
go
--调用存储过程
exec 存储过程名称 

--带默认值存储过程语法
--创建语法  
create proc / procedure   存储过程名称 

--参数

@参数名称  参数类型  默认值  output 输出参数

as

自定义sql业务逻辑
go
--调用存储过程
exec 存储过程名称 

--带output输出的存储过程
if OBJECT_ID('ceshi_a') is not null
drop procedure ceshi_a
go
create procedure ceshi_a
@ceshis int ,
@sex int output
as
	
	set @sex=(select count(*) from Inventory where @ceshis = cInvCode)
go
go
declare @sexs int
--exec ceshi_a @sex ='1002',

exec ceshi_a @ceshis='1002',
@sex = @sexs output
print @sexs
select @sexs as '条数'

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值