How to send data in Excel file from sp_send_dbmail with column name to be bold using database query in a proper format?
Below code is giving me excel file with column names as:
Document ticket_number status 1000. 200043. Pending
I want column name to be bold (Document ,ticket_number ,status) and the data should be in a tabular form otherwise it is not looking good.
My code is:
Declare @body nvarchar(max)
Set @body='<html> <p>hi</p></html>'
Declare @attach nvarchar(max)
Set @attach='refund'+'.xls'
Declare @qry nvarchar(max)
@qry='select document,ticket,status,agent from tbl'
---sending an email
Exec msdb.dbo.sp_send_dbmail
@profile_name='y',
@recipients='ab@gmail.com',
@body=@body,
@body_format='html',
@query=@qry,
@subject='db data',
@attach_query_result_as_file=1,
@query_attachment_filename=@attach,
@query_result_header=1,
@query_result_seperator= '. ',
@query_result_no_padding=1;