Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Number of rows in last cursor

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-01-18 : 10:41:33
Tamar writes "Hello,

I write a smiple script in which I open cursor.
After closing and deallocating the cursor I need to know the number of records I fetched (number of rows in last cursor per connection).

Thanks in advance.
Tamar."

Nazim
A custom title

1408 Posts

Posted - 2002-01-19 : 03:58:14
Y dont u simply use the same conditions of your cursor and run a query like this
select @mcount=count(*) from tablename
where <conditions>
which will give u the count of records .

Anywayz, Check BOL for @@CURSOR_ROWS .this should help you in ur original Q.

HTH

----------------------------------
Dont Tell God how big your Problem is , Tell the Problem how Big your Good is
Go to Top of Page

tbukrinsky
Starting Member

2 Posts

Posted - 2002-01-20 : 03:45:47
quote:

Y dont u simply use the same conditions of your cursor and run a query like this
select @mcount=count(*) from tablename
where <conditions>
which will give u the count of records .

Anywayz, Check BOL for @@CURSOR_ROWS .this should help you in ur original Q.

HTH

----------------------------------
Dont Tell God how big your Problem is , Tell the Problem how Big your Good is



Go to Top of Page

tbukrinsky
Starting Member

2 Posts

Posted - 2002-01-20 : 03:49:23
Hi,

That's what I did to solve it, but I wanted to find the better solution instead of performing the same SQL statement twice.

Thank you.


Go to Top of Page

Nazim
A custom title

1408 Posts

Posted - 2002-01-20 : 07:19:58
you can keep a counter and increment it everytime you fetch next record from the cursor. that will give you the count of records.

HTH

--------------------------------------------------------------
Dont Tell God how big your Problem is , Tell the Problem how Big your God is
Go to Top of Page
   

- Advertisement -