We have an instance that randomly spikes the CPU. I want to create an alert that fires on CPU over 90% and automatically calls a job that runs sp_AskBrent
and emails me the output. However, the output is unreadable in either Text or HTML output. It doesn't even go well into an Excel spread sheet. How can I get the info in a readable format?
Sql-server – How to export the output of sp_AskBrent
database-mailformatsp-askbrentsql server
Related Question
- Sql-server – SSIS unpivot returns different results when run via a SQL agent job
- Sql-server – SQL Server Job is running slow after a few days
- Sql-server – ny way to tell which derived column failed
- SQL Server – Running sp_AskBrent with @ExpertMode = 1 in PowerShell
- Tools – First Response Kit Missing sp_AskBrent
- SQL Server – Can’t Import Flat File
- SQL Server – How to Create SQL Agent Job or Alert for Long Running Queries
Best Answer
Make the alert run a job that runs the
EXEC msdb.dbo.sp_send_dbmail
with the@query
parameter:The
@attach_query_result_as_file = 1
parameter will send the results as an attachment in text format, which should certainly be readable. If you want, you can export the results in comma-delimited format using the@query_result_separator
parameter.From the MSDN page for
sp_send_dbmail
:There are many options for that stored proc; check the MSDN page and likely you'll get the output exactly how you want it.