sysmail_delete_log_sp (Transact-SQL)
Deletes events from the Database Mail log. Deletes all events in the log or those events meeting a date or type criteria.
Use the sysmail_delete_log_sp stored procedure to permanently delete entries from the Database Mail log. An optional argument allows you to delete only the older records by providing a date and time. Events older than that argument will be deleted. An optional argument allows you to delete only events of a certain type, specified as the event_type argument.
Deleting entries in the Database Mail log does not delete the e-mails entries from the Database Mail tables. Use sysmail_delete_mailitems_sp to delete e-mail from the Database Mail tables.
A. Deleting all events
The following example deletes all events in the Database Mail log.
EXECUTE msdb.dbo.sysmail_delete_log_sp ; GO
B. Deleting the oldest events
The following example deletes events in the Database Mail log that are older than October 9, 2005.
EXECUTE msdb.dbo.sysmail_delete_log_sp
@logged_before = 'October 9, 2005' ;
GO
C. Deleting all events of a certain type
The following example deletes success messages in the Database Mail log.
EXECUTE msdb.dbo.sysmail_delete_log_sp
@event_type = 'success' ;
GO