Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Cursor processing record count.

Posted on 2010-11-08
3
Medium Priority
?
566 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 2000 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 2000 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 2000 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

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 article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

722 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