游标:
use teaching
go
declare student_cursor1 cursor
for select *
from student
go
declare student_cursor2 cursor
for select suo,sname
from student
where dept='324'
order by sno
for read only
go
打开游标等操作:
use teaching
go
declare student_cursor4 cursor
for select ok,ko
from sword
where do='1'
order by ok
for read only
go
open student_cursor4
use teaching
go
declare @ko varchar(7),@ok varchar(20)
fetch next from student_cursor4
into @ok,@ko
while @@fetch_status=0
begin
print @ok+@ko
fetch next from student_cursor401
into @ko,@ok
end
close student_cursor4
deallocate student_cursor4
go
存储过程:
CREATE PROCEDURE student_info @ok varchar(20)
AS select ok,ko,do
from sword
where ok=@ok
GO
评论