码迷,mamicode.com
首页 > 数据库 > 详细

sqlserver 存储过程的新建与执行

时间:2019-11-03 15:09:10      阅读:115      评论:0      收藏:0      [点我收藏+]

标签:min   sel   style   begin   create   print   新建   weight   out   

if 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   

原文地址:https://www.cnblogs.com/dinggf/p/11785969.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!