I have a table created in SQL Server which has the following data:
CREATE TABLE [dbo].[LogData](
[id] [int] IDENTITY(1,1) NOT NULL,
[fechahora] [text] NULL,
[descripcion] [text] NULL,
[servidor] [text] NULL,
[horaCaptura] [time](7) NULL,
[fechaCaptura] [date] NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
This table already contains data, but it is linked to an application developed in Python, my users use this table once a day and save more than 14000 records in a day, so in a month it will take up a lot of space in the HDD, and I want to formulate a Procedimiennto almacenado
that I delete these records every 90 days, I have not managed to do it and use DATEADD
in the same way and try with a simple elimination of dates but that is what I do not want because it would be very tedious what I have of procedure
is this:
CREATE PROCEDURE dbo.Sp_ProcesoDiario
AS
BEGIN
DECLARE @tiempo date = DATEADD(day,90,fechaHora)
--DELETE FROM LogData WHERE fechaCaptura <= GETDATE();
DELETE FROM LogData WHERE @tiempo >= GETDATE();
END
I would greatly appreciate it in advance. :)