May 22, 2009 at 4:46 am
How can i automatically delete the database mail logs older than 1 month
May 22, 2009 at 6:11 am
shanila_minnu (5/22/2009)
How can i automatically delete the database mail logs older than 1 month
You can use the system sp for this...search in BOL for these sp:
sysmail_delete_mailitems_sp and
sysmail_delete_log_sp
and I'm sure that you can find more thing how to do that for the logs older than 1 month!
Let me know how is going!
May 22, 2009 at 6:12 am
or try to use the code:
USE MSDB;
GO
DECLARE @DeleteBeforeDate DateTime
SELECT @DeleteBeforeDate = DATEADD(d,-30, GETDATE())
EXEC sysmail_delete_mailitems_sp @sent_before = @DeleteBeforeDate
EXEC sysmail_delete_log_sp @logged_before = @DeleteBeforeDate
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply