【正文】
ists(select name from sysobjects Where name=’ student_pro’ and type=’ p’) Drop procedure student _pro Go Create proc student_pro As Declare sno char(20),sname char(8).mess char(100) Declare s_cursor cursor For Select sno ,sname from student Open s_cursor Fetch next from s_cursor into sno, sname While fetch_status =0 Begin Print ‘學(xué)生列表:’ Select mess=’學(xué)號(hào):’ +sno+’, 姓名:’ +sname Print mess Fetch next from s_cursor into sno, sname end close s_cursor deallocate s_cursor 觸發(fā)器create trigger trigfor on sc for insert asdeclare o char(8) select o=o from inserted if o not in (select o from c) begin print 39。open mycursor2fetch next from mycursor2declare o char(8)declare mycursor scroll cursorforselect o from courseopen mycursorfetch next from mycursor into owhile(fetch_status=0)beginprint39。select top 3* from sc where o=o order by grade descfetch next from mycursor into oendclose mycursordeallocate mycursor六、實(shí)驗(yàn)小結(jié)