DECLARE authors_cursor CURSOR FOR--定义游标 SELECT au_lname FROM authors OPEN authors_cursor--打开游标 FETCH NEXT FROM authors_cursor--提取一条记录 WHILE @@FETCH_STATUS = 0 BEGIN FETCH NEXT FROM authors_cursor--循环记录 END CLOSE authors_cursor--关闭游标 DEALLOCATE authors_cursor--释放
SELECT au_lname FROM authors
OPEN authors_cursor--打开游标
FETCH NEXT FROM authors_cursor--提取一条记录
WHILE @@FETCH_STATUS = 0
BEGIN
FETCH NEXT FROM authors_cursor--循环记录
END
CLOSE authors_cursor--关闭游标
DEALLOCATE authors_cursor--释放