欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

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

程序员文章站 2022-07-29 19:21:46
参考:https://docs.microsoft.com/en-us/sql/relational-databases/system-stored-procedures/sysmail-delete-mailitems-sp-transact-sqlhttps://docs.microsoft.c ......
-- 查询邮件发送记录和报告
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