Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

WAITFOR DELAY in query analyzer

Status
Not open for further replies.

despierto

Programmer
Jun 25, 2004
39
US
Hiya. I am working on a script to be run in query analyzer in which I want to test for a specific instance every x seconds. When I get one of the results I want, (Status is successful, failed, totally failed), I want to kick out of my loop. BUT - I want to see that it is still doing something in the meantime. I set the "Scroll results as received" check box, but that doesn't seem to do what I want.

This little script, as written, shows all the results after 5 seconds. I want to see the 'in progress' every one second, just a friendly reminder that it's still cranking. Any ideas?

Code:
declare @counter int

set @counter=0

while @counter < 5
begin
   print 'in progress'
   waitfor delay '00:00:01'
   set @counter=@counter+1
end
print 'done!'
 
I've never been able to get my results from a while loop until the while loop is finished executing. I'm not sure why that is. Drives me absolutely batty when I'm trying to see the results of each individual select statement while it's processing.

Sorry I don't have an answer, but at least you know you're not alone. @=)



Catadmin - MCDBA, MCSA
"If a person is Microsoft Certified, does that mean that Microsoft pays the bills for the funny white jackets that tie in the back???
 
Maybe that's my problem. I'm always watching it in Grid mode. I'll try text the next time I do that.

Thanks, Denny!



Catadmin - MCDBA, MCSA
"If a person is Microsoft Certified, does that mean that Microsoft pays the bills for the funny white jackets that tie in the back???
 
No, I have it in text mode.... Unfortunately, it still waits until it's done with the loop.

Seperate linear selects will show up as the script executes. Strange, I know...
 
Very strange. I've seen it do all sorts of things when feeding info back via print. Sometimes it will come back in real time, some times it wont. I never have been able to narrow it down to a why.

Denny
MCSA (2003) / MCDBA (SQL 2000)

--Anything is possible. All it takes is a little research. (Me)
[noevil]
Donate to Katrina relief
 
Just to add to your observations, the following code waits to print everything until the query has finished also.

Code:
declare @counter int
print 'declare'
set @counter=0
print 'set'
loopit:
   print 'in progress'
   waitfor delay '00:00:02'
   set @counter=@counter+1
if @counter < 5 
goto loopit
else
print 'done!'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top