Solved

Sending stored procedure results via Email in Sql Server 2005

Posted on 2008-06-20
2
482 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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Extract string portion 2 24
SQl Server 2012 r2 - Why temp table shrinks from large query 4 37
SYbase 4 30
Query Syntax 17 34
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 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.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

770 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