Check the Status of the Database Mail Queues in SQL Server (T-SQL)

In SQL Server, you can use the sysmail_help_status_sp stored procedure on the msdb database to check the status of the Database Mail queues.

Example

To return the Dartabase Mail queue status, simply execute the stored procedure without any parameters.

EXEC msdb.dbo.sysmail_help_status_sp;

Result:

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

The status can be either STOPPED or STARTED. In this case, it happened to be STARTED.

Note that the sysmail_help_status_sp stored procedure is on the msdb database and it’s owned by the dbo schema, and therefore you need to use the three part naming if msdb is not the current database.

Starting/Stopping the Queue

You can start the queue with sysmail_start_sp and stop it with sysmail_stop_sp.

In this example I stop the queue and check the status again:

EXEC msdb.dbo.sysmail_stop_sp;
EXEC msdb.dbo.sysmail_help_status_sp;

Result:

Commands completed successfully.
+----------+
| Status   |
|----------|
| STOPPED  |
+----------+

And start it again:

EXEC msdb.dbo.sysmail_start_sp;
EXEC msdb.dbo.sysmail_help_status_sp;

Result:

Commands completed successfully.
+----------+
| Status   |
|----------|
| STARTED  |
+----------+