游标: use teaching godeclare student_cursor1 cursorfor select * from student godeclare student_cursor2 cursor for select suo,sname from student where dept='324' order by snofor read onlygo 打开游标等操作: use teachinggodeclare student_cursor4 cursor for select ok,ko from sword where do='1' order by okfor read onlygo open student_cursor4use teachinggodeclare @ko varchar(7),@ok varchar(20)fetch next from student_cursor4into @ok,@ko while @@fetch_status=0begin print @ok+@kofetch next from student_cursor401into @ko,@okendclose student_cursor4deallocate student_cursor4 go 存储过程: CREATE PROCEDURE student_info @ok varchar(20)AS select ok,ko,dofrom sword where ok=@okGO

评论