jbalbo (5/6/2013)
Thanks for getting back ,so something like this ?
EXEC msdb.dbo.sp_send_dbmail
@recipients = 'me@email.org',
@query = 'select FName as first,
LName as last
from client where LName = ''wilson'' ''
for xml path(''Referral'')
ROOT(''CLUB'')',
@execute_query_database = 'execute_query_database', <-- NOT SURE what goes here ???
@attach_query_result_as_file = 1,
@body = 'The stored procedure finished successfully.',
@subject = 'Automated Success Message'
@attach_query_result_as_file = 1 makes it an attachment, what if I wanted to name it?
Thanks
Joe
You will need to specify @profile_name, which is the mail profile set up for database mail for these mail notifications. @execute_query_database is the database the query should be run on. Use @query_attachment_filename for the file name you want to use.
--------
For SQL Tips, check out my blog: http://lantztechknowledge.blogspot.com/[/url]
You can also follow my twitter account to get daily updates: @BLantz2455