Question

MY PROBLEM(scenario):

There is a already a built in method call "WAITFOR" that can make the execution of a for example a "Stored Procedure". This waiting can only be done for less than 24 hours.

But the thing is my client who is also a developer wants to find a method to go around this issue and find a way to wait more than 24 hours to reduce the development time.

There is already a method. That can query necessary tables once a day and send the necessary emails to the customers ect..

I know that since this "WAITFOR" is limited to 24 hours, There has to be a performance issue as this number of "WAITFOR" executions go higher (For example 2000).

MY QUESTION:

  1. Is there a way of holding a stored procedure more than 24 hours. Lets say for more than 14 days.
  2. If there is not a method to work this out,,How should I defend on this issue, What are the facts that I can give to my client, Such as Performance Issues,,

This is what I think,, Since this waiting is limited to 24 hours is that there is no other option to give the expected functionality to perform a data base task precisely on time. But this gives a big over head to the server to keep the track of each "WAITFOR" execution. If this is more than 2000 or so,, This is impossible to bear for the server.

The best option available is to have a "SQL Agent Job" that run once a day(as you wish) and get the values that are related to set the WAITFOR to execute some job precisely on time.

Please give me a much better understanding on this issue of waiting for more than 24 hours. To go for the next alternative. :((((

Thanks in advance.

Was it helpful?

Solution

Is there a way of holding a stored procedure more than 24 hours. Lets say for more than 14 days.

Yes, 14 x 24 hour WAITFOR's for example .. but of course that would be terrible beyond all ability to describe; you are forcing a connection to remain open for that period, consuming resources on the server for that period and so on.

What you describe is precisely what an SQL Agent Job is for, use one.

OTHER TIPS

The question about WAITFOR limitation could be solved in easy way- just do "Waitfor" couple of times:

Declare @i int;
Set @i = 0;
While @i < 5
Begin
    Set @i = @i + 1
    WAITFOR DELAY '00:00:01';
End;

If you want to execute some job after a precise time period other alternative could be use service broker (SB) and dialog timer. (i just love SB, so maybe i see the usage for it everywhere..).

In SB you can send message (witch may include time when it should run or you can just put fixed time) and start dialog timer. that way you will not keep connection open.

SB BEGIN CONVERSATION TIMER, and Service Broker.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top