I have a question regarding stored procedures and SQL. I have a job running everyday containing a stored procedure which makes an insert into a database table.
This is the current situation: I have to insert the data about yesterday, in this stored procedure I take the data of today, decrease 1 day and save the elements in my DB, in this way I have the data of yesterday.
This is the desired situation: I have to insert the data about the previous week, starting from yesterday.
In the stored procedure, I want to do the following steps:
- I set the data of yesterday and I make the first insert
- After 25 minutes I decrease one day so that I have the data of 2 days before and I insert the data
- I repeat the same process until the number of days I've defined is lower than a counter I increase every time I make an insert
Question: how in SQL can I write: wait for 25 minutes then do this?
I couldn't simply run the job every 25 minutes because, when I decrease the date (the date is the name of the table such as data_20210926), I should know the starting date (is it today - 3, today - 4 or else) and I can't know this information and the job in my system can't have in input the result of the output of the previous execution