--使用游标输出学生姓名、选修课程名称和期末考试成绩 use teaching go declare @sname nchar(8),@cname nchar(10),@final numeric(6,2)--定义变量 declare sc_cursor cursor --定义游标 for select sname,cname,final from score join student on(score.studentno=student.studentno) join course on (score.courseno=course.courseno) open sc_cursor--打开游标 fetch next from sc_cursor into @sname,@cname,@final--查询 print '学生姓名 课程名称 期末成绩' print '------------------------------' while @@fetch_status=0 begin print @sname+@cname+cast(@final as nchar(6)) fetch next from sc_cursor into @sname,@final end close sc_cursor--关闭游标 deallocate sc_cursor--释放游标
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。