SQL Server / Long Running Queries / Email Alert

This is example of long running queries of database within email alert, we already had example how you can use sp_send_dbmail stored procedure from msdb database to send backup size email daily, and how to send missing indexes report via email. This is just another use case of sp_send_dbmail stored procedure.

I used following arguments to achieve this

@profile_name (name of an existing Database Mail profile, type sysname, default NULL),

If you are not sure about your profile account use the following script, it shows all the accounts for all profiles in the instance.

 

@recipients (Is a semicolon-delimited list of e-mail addresses to send the message to, varchar(max)),

@body (Is the body of the e-mail message, nvarchar(max)),

@subject (Is the subject of the e-mail message, nvarchar(255)),

@body_format (Is the format of the message body, varchar(20))

More information about this system stored procedure you can find here sp_send_dbmail (Transact-SQL)

 

 

Your email result should be similar to

 

After you have sql handle of your expensive query you can then get XML query plans or any other query stats information

 

 

Similar Posts:

Leave a Reply

Your email address will not be published. Required fields are marked *