I am using sp_send_dbmail in SQL Server 2008 to send query results. I moved the request to proc and try to use proc in prceus sp_send_dbmail as follows:
EXEC msdb.dbo.sp_send_dbmail @profile_name = 'myprofile', @from_address = ' email@somedomain.com ', @reply_to = ' email@somedomain.com ', @recipients = ' email@differentdomain.com ', @importance = 'NORMAL', @sensitivity = 'NORMAL', @subject = 'My Subject', @body = 'Here you go.', @attach_query_result_as_file= 1, --@query _result_header = 1, @query_result_width = 1000, @query_result_separator = '~', @query_attachment_filename = 'myFile.txt', @query = 'EXEC dbo.myProc'
I also tried this using 4 parts of the naming in proc; with and without EXEC, etc. It worked fine as a request, but I can't get it to work as a proc. Is it possible?
Dan
source share