Sql-Server 邮件相关的查询和删除

-- 查询邮件发送记录和报告
SELECT TOP(50) * FROM msdb.dbo.sysmail_allitems ORDER BY mailitem_id DESC
SELECT TOP(50) * FROM msdb.dbo.sysmail_event_log ORDER BY log_id DESC

-- 删除指定时间之前的邮件发送记录和报告
EXECUTE msdb.dbo.sysmail_delete_mailitems_sp @sent_before = '2018-03-01 00:00';
GO
EXECUTE msdb.dbo.sysmail_delete_log_sp @logged_before = '2018-03-01 00:00';
GO

  

参考:
https://docs.microsoft.com/en-us/sql/relational-databases/system-stored-procedures/sysmail-delete-mailitems-sp-transact-sql
https://docs.microsoft.com/en-us/sql/relational-databases/system-stored-procedures/sysmail-delete-log-sp-transact-sql

posted @ 2018-02-26 20:46  皮特胖胖  阅读(463)  评论(0编辑  收藏  举报