Solved

Cursor processing record count.

Posted on 2010-11-08
3
528 Views
Last Modified: 2012-05-10
HI, I am running a cursor which is updating around 15000
records in a table.

I need to see the number of records which are getting updated
or processed by the cursor while the query is running..

Can anyone please let me know how do i do that in a easy
manner without affecting the performance of my Cursor ?

Thanks
0
Comment
Question by:gvamsimba
  • 3
3 Comments
 
LVL 58

Assisted Solution

by:cyberkiwi
cyberkiwi earned 500 total points
ID: 34086839
> while the query is running..

You mean like a progressbar counter?  Not possible... unless you want to see the messages keep scrolling like

processing #1
processing #2
processing #3
processing #4
processing #5
etc

which will flood the messages window
0
 
LVL 58

Accepted Solution

by:
cyberkiwi earned 500 total points
ID: 34086849
If you mean a count after the loop is complete, then something like a counter

declare @counter int
set @counter = 0
while @@FETCH_STATUS = 0 begin
      set @counter = @counter + 1
      .....
      fetch next from mycursor .....
end
print convert(varchar(10), @counter) + ' records processed in cursor'
0
 
LVL 58

Assisted Solution

by:cyberkiwi
cyberkiwi earned 500 total points
ID: 34086874
Re the first case, you can use

declare @counter int, @msg varchar(200)
set @counter = 0
while @@FETCH_STATUS = 0 begin
      set @counter = @counter + 1
      set @msg = 'processing #' + convert(varchar(10), @counter)
      RAISERROR(@msg,0,1) WITH NOWAIT;
      .....
      fetch next from mycursor .....
end
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Long way back, we had to take help from third party tools in order to encrypt and decrypt data.  Gradually Microsoft understood the need for this feature and started to implement it by building functionality into SQL Server. Finally, with SQL 2008, …
Data architecture is an important aspect in Software as a Service (SaaS) delivery model. This article is a study on the database of a single-tenant application that could be extended to support multiple tenants. The application is web-based develope…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question