title: Define proper width in csv generated by sp_send_dbmail
body: <p>When i send mail with a csv attachment using sp_send_dbmail, columns are overlapped in file as shown in below</p>
  
  <p><a href="https://i.stack.imgur.com/BIMpL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BIMpL.png" alt="enter image description here"></a></p>
  
  <p>Is there any way to set proper width to columns like this.</p>
  
  <p><a href="https://i.stack.imgur.com/kTh3w.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kTh3w.png" alt="enter image description here"></a></p>
  
  <p>Query i have used is </p>
  
  <pre><code>CREATE TABLE ##sample
  (
  header1 varchar(50),
  header2 varchar(50),
  header3 varchar(50),
  )
  
  INSERT ##sample VALUES ('Samlpe text Samlpe text','Samlpe text Samlpe text','Samlpe text Samlpe text')
  
  INSERT ##sample VALUES ('Samlpe text Samlpe text','Samlpe text Samlpe text','Samlpe text Samlpe text')
  DECLARE @column1name varchar(50),
  @qry VARCHAR(MAX)
  
  SET @qry =
  ('set nocount on; 
  SELECT ''header1'', ''header2'', ''header3''
  UNION ALL
  SELECT  header1,header2,header3
  FROM ##sample')
  
  DECLARE
      @tab char(2) = CHAR(9)
  
  EXEC msdb.dbo.sp_send_dbmail
  @profile_name = 'Mail Profile', 
  @query = @qry,
  @attach_query_result_as_file = 1,
  @query_attachment_filename = 'Report.csv',
  @query_result_separator=@tab,
  @query_result_width =32767,
  @query_result_no_padding=1,
  @body = 'Empty',
  @body_format ='HTML',
  @recipients = 'raju.vadnala@gmail.com', 
  @subject = 'Empty',
  @query_result_header=0
  
  
  drop table ##sample 
  </code></pre>