sqlserver 存储过程的新建与执行
时间:2021-07-01 10:21:17
帮助过:3人阅读
Exists(
select * from sysobjects
where NAME
= ‘insert_custominfo‘ and type
=‘P‘)
drop procedure insert_custominfo
go
create proc insert_custominfo
@mid nvarchar(
50),
@custominfoid nvarchar(
50) output
as
begin
declare @num int
set @num =(
select COUNT(
*)
from t_custominfo
where c_id
=@mid )
if(
@num =0)
begin
insert into t_custominfo(c_id)
values(
@mid)
set @custominfoid = @@IDENTITY
end
else
begin
select @custominfoid=c_custominfoid
from t_custominfo
where c_id
=@mid
end
end
declare @custominfoid int
exec insert_custominfo
‘1101‘,
@custominfoid output
print @custominfoid
sqlserver 存储过程的新建与执行
标签:min sel style begin create print 新建 weight out