I have to start cyclic process in a stored procedure and then have to stop it after some time (after 12-24 hours). Stored procedure's work should not be started twice. SQL Server client (caller) should not wait and should not get execution timeout. How it can be implemented?
CREATE PROC dbo.CyclingProcess
AS
BEGIN
/*
.. how to start or stop process by external caller
*/
WHILE(1 = 1)
BEGIN
EXEC mysp_WorkingProcedure -- some working process...
@input1 = @input1
....
,@delay = @delay output
WAITFOR DELAY @delay
END
END
Clarification:
I have to do some repeated work during long time. I have to start this process and stop it. Why stored procedure? I have to change some input parameters for [some work] and call it again after some delay. Maybe you know other more smart way to implement it. This cyclic process should work in database.