Database mail

  • How can i automatically delete the database mail logs older than 1 month

  • 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!

    ============================================================
    SELECT YOUR PROBLEM FROM SSC.com WHERE PROBLEM DESCRIPTION =
    http://www.sqlservercentral.com/articles/Best+Practices/61537/[/url]

  • 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

    ============================================================
    SELECT YOUR PROBLEM FROM SSC.com WHERE PROBLEM DESCRIPTION =
    http://www.sqlservercentral.com/articles/Best+Practices/61537/[/url]

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply