Reputation: 9
I have a table in SQL which has millions of records and i want to move some of those records to different tables. I want to keep only 3months worth of data from the current date
So any record that is greater than 3 months will be moved. Now there is a datetime column on the table for example a date would be 2024-01-02 , 2023-10-05, this is just an example and those datarows will be moved , but the row that has the year 2024 will be moved to a table named Archive24 and the one with year 2023 will be moved to table Archive23 and if the tables dont exist i assume i will have to test for that in a script ?
Any help would be appreciated as im relatively new to the sql "in depth" scripting
I have a script soi far that gets the data older that 90 days as follows:
SELECT *
FROM TestTable
WHERE StartTime < DATEADD(day, -90, GETDATE());
How can i start to do this using SQL scripts ?
Upvotes: 0
Views: 25