• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 671
  • Last Modified:

SQL Server: selecting query results into variable

I'd like to email results of the sql select query (either 'Results to Text' or 'Results to Grid') using
msdb.dbo.sp_send_dbmail procedure. What are my choices?
0
quasar_ee
Asked:
quasar_ee
1 Solution
 
David ToddSenior DBACommented:
Hi,

http://msdn.microsoft.com/en-us/library/ms190307.aspx
In this you can get the procedure to run the query for you - see the query parameter.

(I note that you've asked this in the MS SQL Server topic, which by convention is the SQL 2000 and earlier queries. Now DBMail is a SQL 2005+ feature, so wont work if your server is SQL 2000.)

Otherwise you could render some html yourself into  varchar variable and use that as the body of the email.

How big is your results set?

Is this on-going or a one-off? How is the results going to be used at the receiver?

HTH
  David
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now