用游标
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 (关闭游标)