November 15, 2019 at 7:46 pm
Im a junior data support analyst and trying to select records from a table with the column ErrorDate and identifying records older than 6 months to delete those records and potentially create a stored procedure; at a minimum, establish a query on our local Wiki to run every 6 months. Any help would be greatly appreciated. Date format for column is YYYY-MM-DD HH-MM-SS.XXX.
November 16, 2019 at 8:10 pm
Thanks for posting your issue and hopefully someone will answer soon.
This is an automated bump to increase visibility of your question.
December 2, 2019 at 2:12 pm
Try something like this:
delete from dbo.test2
where KeyColumn in (
select t.KeyColumn
from dbo.test2 t
where t.ErrorDate <= DATEADD(month,-6,getdate())
)
December 2, 2019 at 2:53 pm
BEFORE YOU DELETE ANYTHING, MAKE SURE THAT YOUR BACKUPS ARE WORKING CORRECTLY AND THAT YOU CAN RESTORE TO A POINT IN TIME!!!!!
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply