|
DECLARE myCursor CURSOR
LOCAL
STATIC
FOR SELECT Name FROM EMP
DECLARE @Name char(20)
OPEN myCursor
FETCH myCursor into @Name
SELECT @@CURSOR_ROWS as CursorRows,
@Name,
@@FETCH_STATUS AS FetchStatus,
CURSOR_STATUS('local', 'myCursor') AS CursorStatus
CLOSE myCursor
DEALLOCATE myCursor
/*
------------------------------
@@Fetch_Status Codes
-------------------------------
0 The Fetch was successful
-1 The Fetch Failed
-2 The row Fetched is missing
--------------------------------
@@CURSOR_ROWS returns the Number of rows in the most recent cursor opened on the connection.
@@FETCH_STATUS returns information about the last FETCH command issued.
*/
|