DECLARE @au_id varchar(11),@au_fname varchar(20) --申明变量
--申明一个游标
DECLARE authors_cursor CURSOR FOR
SELECT au_id, au_fname FROM authors
--打开游标
OPEN authors_cursor
--取出值
FETCH NEXT FROM authors_cursor INTO @au_id, @au_fname
--循环取出游标的值
WHILE @@FETCH_STATUS = 0
BEGIN
Print @au_id
Print @au_fname
Print ''
FETCH NEXT FROM authors_cursor
INTO @au_id, @au_fname
END
CLOSE authors_cursor --关闭游标
DEALLOCATE authors_cursor --释放游标