用光标,如DECLARE authors_cursor CURSOR FOR SELECT au_id, au_fname, au_lname FROM authors
OPEN authors_cursor
FETCH NEXT FROM authors_cursor INTO @au_id, @au_fname, @au_lname
WHILE @@FETCH_STATUS = 0
BEGIN
   -- do something
   ....   -- Get the next author.
   FETCH NEXT FROM authors_cursor INTO @au_id, @au_fname, @au_lname
END
CLOSE authors_cursor
DEALLOCATE authors_cursor