Advertisement

11.28.2007 at 05:41AM PST, ID: 22987438
[x]
Attachment Details

using sp_send_dbmail to email a query result set in html format

Asked by sapainca in SQL Server 2005

Tags: sp_send_dbmail, html, query, format, result

I have the following:

EXEC msdb.dbo.sp_send_dbmail
@recipients=N'email@address',
@body='None',
@subject ='Subject',
@body_format = 'HTML',
@profile_name = 'Profile',
@query ='set nocount on; exec dataDayStrip 657,4,7; set nocount off;',
@attach_query_result_as_file = 0,
@query_result_header = 1,
@query_result_width = 1000,
@exclude_query_output = 1,
@query_result_separator = ';'

This all works fine, except the email I receive includes the output of "dataDayStrip" procedure as unformatted and unreadable gobblygook.  I'd like to format it into HTML (or another format possibly).  How can I either do this automatically, or get a reference to the query result as a string to parse it manually or through another stored procedure? Or call the procedure and save the result set into a string and then parse that variable and then pass it along to the @body of the email.

The procedure that is being called uses dynamic sql and returns a simple resultset.Start Free Trial
 
Loading Advertisement...
 
[+][-]11.28.2007 at 06:23AM PST, ID: 20365598

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.29.2007 at 04:09AM PST, ID: 20372872

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12.01.2007 at 06:57AM PST, ID: 20388149

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12.02.2007 at 08:14PM PST, ID: 20393613

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12.04.2007 at 12:03PM PST, ID: 20405886

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12.04.2007 at 01:31PM PST, ID: 20406746

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: SQL Server 2005
Tags: sp_send_dbmail, html, query, format, result
Sign Up Now!
Solution Provided By: Yveau
Participating Experts: 1
Solution Grade: B
 
 
[+][-]12.04.2007 at 04:22PM PST, ID: 20408023

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628