HI WELCOME TO KANSIRIS

Remove unsent database email from SQL Server

Leave a Comment
Suppose, you are sending mail to different-different users by using while loop and you forgot to insert while loop update statement. In this case SQL Server will generate thousands or millions of mail against a specific email address with in a min.
To stop SQL Server for sending unwanted mails we required to clean the unsent mail from database mail queue. We can do this by running below queries.

  1. SELECT * FROM msdb.dbo.sysmail_event_log;

  2. -- To get number of unsent emails

  3. select count(*) from msdb.dbo.sysmail_unsentitems;

  4. -- remove all the unsent emails

  5. delete from msdb.dbo.sysmail_unsentitems;


Now all the unexpected email hav been removed from SQL Server database mail queue.
Summary
In this article I try to explain how can you remove unsent email from database mail queue. I would like to have feedback from my blog readers. Please post your feedback, question, or comments about this article.

0 comments:

Post a Comment

Note: only a member of this blog may post a comment.