@ Cursor_rows

Source: Internet
Author: User
@ Cursor_rows

Returns the number of qualified rows in the cursor that is last opened on the connection. To improve performance, Microsoft SQL server can asynchronously populate large key sets with static cursors. You can call @ cursor_rows to retrieve the number of rows that match the cursor when it is called.

Return Value Description
-M The cursor is asynchronously filled. Return Value (-M) Is the current number of rows in the key set.
-1 The cursor is dynamic. Because dynamic cursors reflect all changes, the number of rows that match the cursors is constantly changing. Therefore, it is never certain that all rows that meet the condition have been retrieved.
0 No opened cursor, no rows that match the last opened cursor, or the last opened cursor has been closed or released.
N The cursor is fully filled. Return Value (N) Is the total number of rows in the cursor.

Syntax

@ Cursor_rows

Return type

Integer

Note

If the last opened cursor is asynchronously opened, the value returned by @ cursor_rows is a negative number. IfSp_configure Cursor thresholdIf the value is greater than 0, the keyset driverProgramOr the static cursor is opened asynchronously, and the number of rows in the cursor result set exceeds the cursor threshold.

Example

The following example declares a cursor and uses select to display the value of @ cursor_rows. Before the cursor is opened, set the value to 0. If the value is-1, the cursor key set is asynchronously filled.

 
Use pubs
Select @ cursor_rows as 'A'
Declare authors_cursor cursor
Select au_lname from authors
Open authors_cursor
Fetch next from authors_cursor
Select @ cursor_rows as 'bb'
Close authors_cursor
Deallocate authors_cursor
----------- 0 (1 row (s) affected) au_lname -------------------------------------- white (1 row (s) affected) ------------1 (1 row (s) affected)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.