Solved

Sending stored procedure results via Email in Sql Server 2005

Posted on 2008-06-20
2
473 Views
Last Modified: 2010-03-20
Hello,
I can a vendor stored procedure that displays data after it runs. I would like to capture that data and have Database Mail send me those data. I've made some attempts to configure it but had no luck.

here is what I have so far:

stored procedure : dbo.cms_load

sample results :
Warning: Null value is eliminated by an aggregate or other SET operation.
Warning: Null value is eliminated by an aggregate or other SET operation.
Warning: Null value is eliminated by an aggregate or other SET operation.
Warning: Null value is eliminated by an aggregate or other SET operation.
Warning: Null value is eliminated by an aggregate or other SET operation.
Warning: Null value is eliminated by an aggregate or other SET operation.
Warning: Null value is eliminated by an aggregate or other SET operation.
Warning: Null value is eliminated by an aggregate or other SET operation.
Warning: Null value is eliminated by an aggregate or other SET operation.

EXEC msdb.dbo.sp_send_dbmail
@recipients=N'ruben.edouard@xxx.com',
@subject ='ARCS Load Finished!',
@profile_name ='2005 DB Mail',
@query ='',
@attach_query_result_as_file = 0

but I don't know how to incorporate the stored procedure results to the above email configuring. Should I place the stored procedure in the @query section?
0
Comment
Question by:redouard
2 Comments
 

Author Comment

by:redouard
Comment Utility
Please help :)
0
 
LVL 51

Accepted Solution

by:
tedbilly earned 125 total points
Comment Utility
Those messages aren't in the same memory space as the T-SQL itself.  As far as I know you can't capture them in SQL.

If you wrote a .NET application that runs the stored procedure the SqlConnection class has a callback mechanism that traps these errors.

http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection.infomessage.aspx
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now