January 30, 2008 at 3:26 pm
I'm having trouble determining the number of rows in a cursor. Here is a snippet of code:
DECLARE curPT CURSOR FAST_FORWARD FOR SELECT * FROM PT WHERE cGID = '1234567890'
OPEN curPT
PRINT @@ROWCOUNT
This always prints 0. I know that 2 records exist in table PT.
January 30, 2008 at 3:57 pm
@@ROWCOUNT returns the number of rows impacted by the last statement, which in this case is the OPEN. The OPEN didn't impact any results, and that is why you got a zero.
What you need is a STATIC cursor and @@CURSOR_ROWS
Good Luck!
Chad
January 30, 2008 at 4:13 pm
Thanks Chad - That worked great!
May 27, 2010 at 4:44 am
[font="Verdana"]
Chad Crawford (1/30/2008)
@@ROWCOUNT returns the number of rows impacted by the last statement, which in this case is the OPEN. The OPEN didn't impact any results, and that is why you got a zero.What you need is a STATIC cursor and @@CURSOR_ROWS
Good Luck!
Chad
[/font]
[font="Verdana"]Hi,
But do u can elaborate its performance degradation? You may know already, and ppl suggests another to this as [highlight]Count()[/highlight] function, but i am unable to fix it up in code.
But again Count() is also controversial. Any good/excellent alternative!
Another one was of [highlight]INSENSITIVE[/highlight] .... . but what's its results on performance... !!!
Thank you.[/font]
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply