I have a cursor containing several columns from a row, which it returns, which I would like to process immediately. I notice that most of the examples that I see about how to use cursors show that they assign a specific column from the cursor to the scalar value one at a time, and then move on to the next line,
eg.
OPEN db_cursor FETCH NEXT FROM db_cursor INTO @name WHILE @@FETCH_STATUS = 0 BEGIN --Do Stuff with @name scalar value, then get next row from cursor FETCH NEXT FROM db_cursor INTO @name END
I want to know if this can do the following:
OPEN db_cursor FETCH NEXT FROM db_cursor; WHILE @@FETCH_STATUS = 0 BEGIN SET @myName = db_cursor.name; SET @myAge = db_cursor.age; SET @myFavoriteColor = db_cursor.favoriteColor;
Help is always appreciated.
sql sql-server tsql cursor
kingrichard2005 Feb 11 '11 at 23:10 2011-02-11 23:10
source share