November 30, 2007 at 2:03 pm
Hi Gurus
I need to write a query which can run every 15 minutes till count(*) in the table becomes 0(zero).
declare @Records INT
set @Records = select count(*) from Mytable
where duration < 100
duration will be updated continuously. I want to make sure every row in the table has duration = 100
and I want to run sql query every 15 minutes in a loop till that happens. Every 15 minutes I want to print time and total number of records on the screen
Is it possible by using only Sql query ??
Thanks in Advance.
Mayur
November 30, 2007 at 2:25 pm
are you not able to use a job for this?
November 30, 2007 at 2:59 pm
Or... you could kick off the proc and do a WAITFOR DELAY 'hh:mm:ss'.
Of course, if the server get's taken down or the job ever fails, you need to manually restart it.
Suggestion of creating a "job" for it is probably the best.
--Jeff Moden
Change is inevitable... Change for the better is not.
November 30, 2007 at 8:54 pm
I want to make sure every row in the table has duration = 100
I would consider a trigger to catch any attempt to save duration <> 100 in the table.
What to do when it's happened - it's up to you.
Either report it immediately or store a record in another table which will be inspected on regular basis.
_____________
Code for TallyGenerator
November 30, 2007 at 11:22 pm
Better opt out for a job and schedule to run every 15 mins
Cheers,
Sugeshkumar Rajendran
SQL Server MVP
http://sugeshkr.blogspot.com
December 1, 2007 at 12:15 am
Hi,
The best and most flawless solutions is to make a job. 🙂
Regards
Take Care
Avaneesh.
Viewing 6 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply