每日博客
数据库
CREATE PROCEDURE prl As BEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. SET NOCOUNT ON; -- Insert statements for procedure here SELECT cOUNT(*)from sc where Grade<60 END GO
CREATE PROCEDURE pr3 As BEGIN declare @dj int , @cname char (20 ) , @cno char (6) , @sno char (9) , @grade int declare cur_cn0 cursor for select grade , cno , sno from scopen cur_cno fetch next from cur_cno into @grade , @cno ,@sno print'学号 课程号 等级' print '=================' while @@FETCH_STATUS=0 begin if(@grade between 81 and 100)set @dj=5 else if(@grade between 61 and 80)set @dj=4 else if(@grade between 41 and 60)set @dj=3 else if(@grade between 21 and 40)set @dj=2 else set @dj=1 print @sno +''+@cno+''+@dj+' ' print '-----------------' fetch next from cur_cno into @grade , @cno , @sno end print '================='close cur_cno END GO