存储过程使用实例

来源:互联网 发布:淘宝封号怎么解封 编辑:程序博客网 时间:2024/05/17 08:41

 

create  PROC usp_stu_download

  @stuid varchar(20)

as

declare @teachid varchar(20)

select @teachid=sdeptcode from stu_dept where nlevel =1

begin tran

delete from stu where stuid = @stuid

select * into #stu_tmp from stu where teachid=@teachid

update #stu_tmp set stuid = @stuid

insert into stu select * from #stu_tmp

if @@error =0 

  drop #stu_tmp

  commit tran

else

  drop #stu_tmp

  rollback tran

 

原创粉丝点击