【正文】
加以測試。執(zhí)行語句為:create procedure stu_proc1 @depart char(20)=39。%39。,@name varchar(8)=39。林%39。as select ,sname,DATEDIFF (year,birth,getdate())as age,ame,grade from student ,sc ,course where student .sno= and =course .o and sdept like @depart and sname like @name exec stu_proc1。exec stu_proc139。計算機系39。,39。張虹39。(2)創(chuàng)建一個名為studentsc的存儲過程,可查詢某學號段的同學的學號、姓名、總成績(學號起始號與終止號在調(diào)用時輸入,可設(shè)默認值),執(zhí)行該存儲過程。執(zhí)行if exists (select name from sysobjects where name=39。student_sc39。and type=39。p39。) begin print 39。已刪除!39。 drop procedure student_sc endelseprint 39。不存在,可創(chuàng)建!39。gocreate procedure student_sc@sno1 nchar(8),@sno2 nchar(8)asselect ,sname,sum(grade)總成績from student,sc,coursewhere = and = and =@sno1 and =@sno2group by ,sname execute student_sc 39。2011000039。,39。2011000339。 建帶輸出參數(shù)的存儲過程(1)創(chuàng)建一個名為coursce_averagede 的存儲過程,可查詢某門課程考試的平均成績。總成績可以輸出,以便進一步調(diào)用。 執(zhí)行語句為: create