In this article I will explain with an example, how to clear mail queue in
SQL Server.
This article is applicable to following
SQL Server versions i.e. 2008, 2008R2, 2012, 2014, 2016, 2017, 2019 and 2022.
Queued Email in SQL Server
The queued emails can be seen in msdb.dbo.sysmail_unsentitems table.
SELECT * FROM msdb.dbo.sysmail_unsentitems
Deleting unsent emails in Queue
In order to delete unsent emails from queue, you need to execute the following DELETE query.
DELETE FROM msdb.dbo.sysmail_unsentitems