Solved

Sending stored procedure results via Email in Sql Server 2005

Posted on 2008-06-20
2
478 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
ID: 21834652
Please help :)
0
 
LVL 51

Accepted Solution

by:
Ted Bouskill earned 125 total points
ID: 21836491
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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Advice on encrpting some store produces on MS SQL  sql 5 30
Help with SQL field formatting 3 20
mySQL Syntax 7 34
Getting max record but maybe not use Group BY 2 17
PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

895 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

12 Experts available now in Live!

Get 1:1 Help Now