How do I get job failure notification to attach the output of the SQL query?

I am using the Job Notification features of SQL Server 2005 to periodically scan certain database tables for records containing bad return codes.  When bad return codes are detected, the SQL Server job uses the RAISERROR command to trigger an error severe enough to cause the job to fail.  When the job failure occurs, the notification is setup to send an e-mail to a specific e-mail address.  I would like the output of the job (i.e. SQL query) to be attached to the notification e-mail or available in the text body.  Is there any way to accomplish what I would like to do using SQL Server 2005?
MicroAutomationAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

chapmandewCommented:
Yes....database mail can be used for this.

http://articles.techrepublic.com.com/5100-10878_11-6164310.html
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
MicroAutomationAuthor Commented:
Thanks.  I reviewed the article and understand how it can be done using a stored procedure, but I was hoping to use the native Notification features available with SQL Server Jobs.  Is there no way to add attachments to a Job Notification?  Or, do I need to do the notification within my SQL Server job using the EXEC msdb.dbo.sp_send_dbmail stored procedure?
 
0
chapmandewCommented:
You can setup alerts on jobs for failures, but you'll need to cofigure an operator to do so.  I think it is just easier to add a job step and revert flow to it upon failure.  Can easily control the message you send.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2005

From novice to tech pro — start learning today.