I need to implement a delete proc to delete all records from a table which are older than 60days.
I just wrote a proc and compared with a field (dtInsert) from the table.....I feel I went wrong somewhere....I need help to correct this proc.....
ALTER PROCEDURE [dbo].[pr_Expire]
SET NOCOUNT ON;
--Calculate expiration date
DECLARE @expire DATETIME
SEt @expire = GETDATE()
SET @expire = DATEADD(day,-60,@expire)
--Expire all records older than @expire
DELETE FROM dbo.CP_EquiP
WHERE dtInsert < @expire