关于存储过程的问题?????
create procedure Add_Student_Info
@student_name char(8),
@student_sex char(2),
@student_age tinyint,
@student_dempt char(20),
@student_major char(20),
@student_year smalldatetime,
@student_no char(13) output
as
begin
declare @temp char(13)--用来提取游标中的数据
set @student_no= 'XH '+convert(varchar(20),Year(@student_year))
if Month(@student_year) <10
set @student_no=@student_no+ '0 '+convert(varchar(20),Month(@student_year))
else
set @student_no=@student_no+convert(varchar(20),Month(@student_year))
if Day(@student_year) <10
set @student_no=@student_no+ '0 '+convert(varchar(20),Day(@student_year))
else
set @student_no=@student_no+convert(varchar(20),Day(@student_year))
declare fetch_max_xh cursor local scroll
--声明一个局部游标用来提取当前日期的最大学生学号
for
select max(student_no) from tb_student_temp where student_year> =
floor(convert(float,@student_year)) and student_year <
floor(convert(float,@student_year))+1;
if CURSOR_STATUS( 'local ', 'fetch_max_xh ')=-1
--如果游标没有打开
Open fetch_max_xh
Fetch first from fetch_max_xh into @temp
CLOSE fetch_max_xh
Declare @id int
if @temp is null
begin
set @student_no=@student_no+ '001 '
end
else
begin
set @id=convert(int,substring(rtrim(@temp),11,10))
if @id <9
set @student_no=@student_no+ '00 '+convert(varchar(20),@id+1)
else
if @id <99
set @student_no=@student_no+ '0 '+convert(varchar(20),@id+1)
else
set @student_no=@student_no+convert(varchar(20),@id+1)
end
insert into tb_student_temp values(@student_no,@student_name,@student_sex,
@student_age,
&