sql的游标用法举例(Cursor)

sql的游标用法举例

 

DECLARE @Name varchar(40), @TrueName varchar(20)
Declare authors_cursor Cursor
For
    Select Name,TrueName
    From   Account

Open authors_cursor

Fetch Next From authors_cursor
INTO @Name, @TrueName

While @@FETCH_STATUS = 0
Begin
    Print @TrueName+CONVERT(Varchar(10),@@FETCH_STATUS)
              Fetch Next From authors_cursor
    INTO @Name, @TrueName

End

Close authors_cursor
Deallocate authors_cursor

 

posted on 2015-01-06 16:15  狼来了  阅读(312)  评论(0编辑  收藏  举报