Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Administration (2000)
 LOOP in Query Analyzer

Author  Topic 

asarak
Starting Member

36 Posts

Posted - 2005-11-14 : 08:55:15
I would like to run continously the following statements
But i don't know how.
I try to use goto with waitfor delay but no effect.

Any help???

loop1:
use master
waitfor delay '000:00:02'
select spid,status,loginame,cmd,hostname,cpu,blocked from sysprocesses where blocked>0
select count(*) blockings from sysprocesses where blocked>0
select count(*) spids from sysprocesses where status like '%run%'
goto loop1


Regards

ASARAK

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-11-14 : 09:18:59
for monitoring use SQL Profiler. It was meant for that.
why would you want to this is beyond me...

while true
begin
--your stuff
end




Go with the flow & have fun! Else fight the flow
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-11-14 : 09:21:15
or

Put that code without loop in sp and insert records to some audit tables; schedulte it and run it as job

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2005-11-14 : 09:22:50
Spirit1, I think your mixing your languages again
while 1=1
begin
--your stuff
end

Be One with the Optimizer
TG
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-11-14 : 09:31:32
lol


Go with the flow & have fun! Else fight the flow
Go to Top of Page

asarak
Starting Member

36 Posts

Posted - 2005-11-14 : 09:33:26
i think that this kind of loop (while) it is running continously but i didnt take any reply until i stop it.
I just run it, show the records and run it again
and i am going to try madhivanan's solution....
Go to Top of Page
   

- Advertisement -