tags:

views:

165

answers:

2

Can we schedule a Stored Procedure to run every 3 seconds in SQL server 2005 ? I could not find a way to schedule it so currently i am calling from front-end. The schedular interface allow minimum 1 minute of scheduling.

A: 

I dont know about run shcedule every 3 seconds, but you can write in step multiple invokes of your procedure with waitfor procedure:

WAITFOR DELAY '00:01'
x2
X2,It is great. so what is the best way WHILE TRUEBEGIN WAITFOR DELAY '00:03' EXECUTE @n = dbo.WorkerSPEND
Manjoor
+3  A: 

You can schedule it every minute to run 20 times in a loop with waitfor delay 3 seconds. Or even to run continuously in a loop with 3 second waitfor delays.

In SQL 2005 and on you can use Conversation Timers to launch activated procedures at 1 second resolution timer.

On a side note, I highly doubt such scheduling is ever necessary.

Remus Rusanu
+1:That's an interesting solution, although I also agree with your final point.
John Sansom
Rusanu,Thanks for your response. it is a real world need to call it every 3 secodns. the application is ruuning fine. i just want to do it in background so i do not need to run a exe to call it.
Manjoor