I am developing a custom system for scheduling task & I am following Microsoft SQL Server Agent approach to schedule task.
I have replicated sysschedules
table for capturing users scheduling occurrences and timings.
Now I need to know how SQL Server get the Next_run_date
and time from this table.
I have found a solution on the internet which are using sysjobhistory
table to get the next run date, but in my case, I have an only sysschedules
table. So, what is the formula to calculate the next_run_date
and time for any job?
Note: I am looking for entire code, concept/algorithm will work for me.