Click here to Skip to main content
16,011,358 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have cursor opened state ,I tried to retrieve the number rows in it through @@CURSOR_ROWS,it gives -1,how can solve this problem. pls help me
Posted

1 solution

You should use
SQL
FETCH NEXT FROM <my_cursor>;</my_cursor>

The cursor returns a total number of rows when it fully populated. Otherwise you may get a different result. Please see @@CURSOR_ROWS (Transact-SQL)[^] for details

upd.
I suppose that you are getting this beacause of asynchronous cursor operation. So you may do the following sp_configure cursor threshold -1 to enable keysets to generate synchronously. Please refer these links for details:
How to: Configure the cursor threshold Option[^]
cursor threshold Option[^]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900