Solved

Cursor processing record count.

Posted on 2010-11-08
3
505 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
Comment Utility
> 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
Comment Utility
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
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

In SQL Server, when rows are selected from a table, does it retrieve data in the order in which it is inserted?  Many believe this is the case. Let us try to examine for ourselves with an example. To get started, use the following script, wh…
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

763 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now