title: Send two different attachment from two different query's in mail from SQL
body: <p>I want to attach two different files from two different queries; this is my code which are causing the error mentioned in the title of this question:</p>
  
  <pre><code>EXEC msdb.dbo.sp_send_dbmail 
       @profile_name='MyTestMail
       @body = @body,
       @body_format ='HTML',
       @recipients = 'xyz@zyx.com',
       @subject = @SBJ,
       @importance = HIGH,
       @sensitivity= Confidential,
       @query = 'Select * from XXXXXXXX;',
       @attach_query_result_as_file = 1,
       @query_attachment_filename = 'X1.csv',
       @query_result_separator=',',
       @query_result_width =32767,
       @query_result_no_padding=1,
       @query = 'Select * from XXXXXXXX2;',
       @attach_query_result_as_file = 1,
       @query_attachment_filename = 'X2.csv',
       @query_result_separator=',',
       @query_result_width =32767,
       @query_result_no_padding=1;
  </code></pre>
  
  <p>I Can successfully send one file as attachment from same code if not repeat query for XXXXXXXX2.</p>