Solved

Cursor processing record count.

Posted on 2010-11-08
3
560 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

631 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