//****例子
//****有一个存储高用,添加修改存储过程
create proc proc_user_insert
(
@usercode varchar(20),
@username varchar(30)
)
as
insert into tb_usert(usercode,username) value (@usercode,@username)
--修改存储过程
create proc proc_usert_update
(
@usercode varchar(20),
@username varchar(30)
)
as
update tb_usert set username=@username where usercode=@usercode
//____调用添加修改存储过程
create proc proc_user_insertorupdate
(
@usercode varchar(20),
@username varchar(30)
)
as
begin
--查找用户表,如果用户存在,则更新,否则添加
select * from tb_user usercode=@usercode
if(@@rowcount<=0)
begin
--调用添加存储过程
exec proc_user_insert @usercode,@username
end
else
begin
--调用修改程序过程
exec proc_user_update @usercode,@username
end
end