snowal raj

snowal raj

  • NA
  • 166
  • 37.4k

how to set auto fit in excel in sql

Dec 14 2016 11:03 PM
Hai,
          
          Every day i send report excel file to my client .so i create job to send mail using "SP_SEND_DBMAIL",Its working properly but.i can't set autofit colums in excel 
 
this is a query for send mail
use msdb
go
DECLARE @SUB VARCHAR(100)
SET @SUB = (SELECT 'Daily Sales Report on '+ replace(convert(NVARCHAR, getdate(), 106), ' ', '/'))
EXEC sp_send_dbmail @profile_name='test Profile',
@recipients='[email protected]', @subject=@SUB,
@body='Attachment File Sent',
@query=select * from tr_sales_mas,
@query_attachment_filename='test.csv',
@attach_query_result_as_file=1,
@exclude_query_output=1,
@query_result_separator=' ',@query_result_width =32767,
@query_result_no_padding=1,
@query_result_header =1
go
how to set auto fit to  excel columns
 
 

Answers (1)