Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combining a Query within a Variable String

Status
Not open for further replies.

pagey47

IS-IT--Management
Joined
Jun 7, 2004
Messages
32
Location
GB
Im Looking to create a email that will have 3 tables aswell as some text as the body. I was thinking of declaring a variable and then building it up. Something like this...

SET @MESSAGE = 'Intro Text' +
SELECT * FROM ORDERS +
'Other Text'

etc..

I was just wondering if this was possible and if so what is the syntax. Ive been playing about but so far without any luck.

Thanks in advance
Nigel
 
You can combine text with the results of a query like this:

Code:
EXEC master..xp_sendmail @recipients = 'me@mydomain.com',
	@subject = 'Test',
	@message = 'This is the email text',
	@query = 'SELECT foo FROM bar'

But I don't think you can have text, then a query, then some other text etc.

--James
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top