I have a table which has more than 90 million rows, it has data for more than 3 years. I want to keep all the records added on Monday (or any one specific day in a week) and delete the remaining records for the data added a year before.
Can any one help me with this?
The difficulty I am facing is to sort out the data that was added on Monday (or any specific day of the week)
You can use datepart
DATEPART(dw, '2007-04-21 ') = 2 // day of the week.
DATENAME(weekday, '2007-04-21 ') = 'Monday'
More can be found https://learn.microsoft.com/en-us/sql/t-sql/functions/datepart-transact-sql?view=sql-server-2017