Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Mail Attachment Error

Author  Topic 

gsavitha
Starting Member

3 Posts

Posted - 2011-02-01 : 05:27:59
Hi all,


EXEC msdb.dbo.sp_send_dbmail
@recipients='sg@domainname.com',
@body='Message Body',
@subject ='Message Subject',
@profile_name ='test',
@query ='select top 10 * from [databasename].dbo.cst ',
@attach_query_result_as_file = 1,
@query_attachment_filename ='Results.csv'

This query is working.

But the dataas in the Result file which i getting in mail is not properly organised.and scrated.What i need to do to get the mail attachment file in correct format as look likes in sql query result??

Any help would be highly appreciated.Thanks in advance..

yadhu_cse
Constraint Violating Yak Guru

252 Posts

Posted - 2011-02-02 : 00:21:35
try to use bellow

EXEC msdb.dbo.sp_sEND_dbmail
@profile_name='test',
@recipients = 'abc @ABC.com',
@body = 'wel come',
@body_format ='HTML',
@subject ='Replacement Tokens',
@query = 'select * from northwind.dbo.Categories',
@query_result_header=1,
@query_result_separator=' ',
@attach_query_result_as_file = 'TRUE',
@query_result_no_padding=1,
@query_result_width=500 ;

try remove padding and adding padding
Go to Top of Page
   

- Advertisement -