April 23, 2022 at 3:09 am
I have a table that I get on the 1st of each month, and it has all the jobs scheduled for the entire month:
SELECT [plannedstart]
,[plannedend]
,[machine]
,[Job]
,[Qty]
FROM ScheduleJobs
Day 1: The table has all the jobs scheduled for the entire month (Original Table)
Days 2: I get another table that has the entire month of the job scheduled minus day 1 data
Day 3: I get another table that has the entire month of the job scheduled minus the day 1 and day two data
Day 4: I get another table that has the entire month of the job scheduled minus the day 1, day 2, and day 3
And the same pattern goes for the rest of the month, day 5, day 6, until the last day of the month.
I want to write a query that allows me to update the Original table daily to keep only the previous day's data and replace the rest of its data with the subsequent current day's data.
Any suggestion on how to accomplish this will be greatly appreciated.
Thanks.
April 23, 2022 at 3:31 am
keep only the previous day's data and replace the rest of its data with the subsequent current day's data.
DELETE
FROM MyTable
WHERE [DateColumn]<GETDATE()-1
INSERT INTO MyTable
SELECT ...
FROM OtherTable
WHERE [DateColumn] = GETDATE()
?
April 23, 2022 at 1:59 pm
Thank you, pietlinden. I appreciate it.
June 21, 2022 at 5:10 am
I'm especially stayed aware of the article and I will get many benefits from it. Subsequently, thank you for sharing it.
June 21, 2022 at 5:10 am
I'm especially stayed aware of the article and I will get many benefits from it. Subsequently, thank you for sharing it.
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply