Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8279673
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T09:24:24+00:00 2026-06-08T09:24:24+00:00

I’ve got a very long query for our SQL Server 2000 database, and I

  • 0

I’ve got a very long query for our SQL Server 2000 database, and I am returning the results for further processing by my C# application.

Consider this query:

declare @sn varchar(20)

select distinct serial_number 
from manufacturingData 
where '7/19/2012'<date_time
order by serial_number

while (0 < (select count(serial_number) from #sn)) begin
  select top 1 @sn=serial_number from #sn
  exec sp_GetSnData @sn
  delete from #sn where serial_number=@sn
end
drop table #sn

I am writing this query on 07/19/2012, so it is only returning records from today.

The query above (for half of today), returned 119 distinct serial numbers and took 52 seconds to execute with the while loop that accompanies it.

Typically, this report is executed for a 30-day period, and there are around 3500 part numbers.

Is there a way to “hook into” the result set so that I can have access to the results as they are generated?

The way it is now, no one knows if the query is going to take 2 minutes or 2 days …or if it is even still doing anything! Does the manager shut down his computer and go home for the day or is this report query just about done?

Once the individual tables are returned, then I need to process each table individually.

It would be nice if I could

  • find out how many distinct items were returned,
  • what item is currently being queried, and
  • have the resulting table available to process while waiting for the next table to come in.

Is this possible?

FYI: I currently do this in my Windows Form, by sending individual requests to our Server, but this is bogging the Server down and using up all of the available connections.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T09:24:26+00:00Added an answer on June 8, 2026 at 9:24 am

    Well based on your comments I’d be tring to optimise the stored proc.

    But if you just want to give some quick and simple indication of how long it will take

    just do

    select Count(distinct serial_number)  from manufacturingData  where '7/19/2012'< date_time 
    

    and multiply it by some fiddle factor say .5 second based on your rough performance figures.

    If you want progress, then have a look at sql server DMO
    Basically you put a Print Statement inside your loop “Processing 1 of 119 say”. SMO will pick up the output and trigger an event, you add a handler to drive a say a progress bar.

    Note DMO works with 2000, and you can get a backwards compatibility pack so it will work with 2005 and 2008. It does (at the moment also work with 2012), but it’s not supported and you’d be mad to rely on it continuing to do so. From 2005 DMO was replaced with SMO.

    Me I’d be working on optimsising the sp first though for any quick wins.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I've got a string that has curly quotes in it. I'd like to replace
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
i got an object with contents of html markup in it, for example: string
I have a view passing on information from a database: def serve_article(request, id): served_article
I would like my Web page http://www.gmarks.org/math_in_e-mail.txt on my Apache 2.2.14 server to display
I have a reasonable size flat file database of text documents mostly saved in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.