How to Stop/Start the Database Mail Queue in SQL Server (T-SQL)

If you’re using Database Mail in SQL Server, you may occasionally need to stop or start the mail queue.

You can do this with T-SQL by using the sysmail_stop_sp stored procedure to stop the queue, and the sysmail_start_sp procedure to start it.

Stop the Queue

Here’s how to stop the queue:

EXECUTE msdb.dbo.sysmail_stop_sp;

You can also use the sysmail_help_status_sp stored procedure to verify that the queue has been stopped.

EXECUTE msdb.dbo.sysmail_help_status_sp;

Result:

+----------+
| Status   |
|----------|
| STOPPED  |
+----------+

Start the Queue

Here’s how to start the queue and check its status:

EXECUTE msdb.dbo.sysmail_start_sp;
EXECUTE msdb.dbo.sysmail_help_status_sp;

Result:

+----------+
| Status   |
|----------|
| STARTED  |
+----------+

Location of the Stored Procedures

Note that all stored procedures on this page are located in the msdb database, and they’re owned by the dbo schema.

Therefore, you’ll need to use the three part naming if you execute them from outside the msdb database.

Alternatively, you can switch to the msdb database first (using USE msdb;) and then run them from there.