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