Include query output in alert notification email body

by Mar 4, 2021

I was wondering if you could include query content in the body of an email notification alert.  Fore example for replication errors I would like to execute sp_replcounters and included the result in the alert body along with the alert.

Response

Scott Stone over 2 years ago
Good idea.

Would including just the beginning of the SQL help? Since some statements can be very long we would probably need to clip it.

eric81 over 2 years ago
Yes I agree you would have to implement restrictions on query output to be included in the alert, but regardless I would find this additional feature since many alerts provide basic information. By having the ability to add additional output it really helps administrative staff assess the issue and pinpoint the problem much faster.