---
chain:
  -
    name: 'query_mssql'
    ref: 'mssql.execute.query'
    parameters:
      query_string: '{{query_string}}'
      params: '{{params}}'
      database: '{{database}}'
    on-success: 'email_results'
  -
    name: 'email_results'
    ref: 'core.sendmail'
    parameters:
      send_empty_body: False
      attachments: '{{query_mssql.result.output_files | join(",")}}'
      subject: '{{email_subject}}'
      body: '{% if query_mssql.result.output_files | length > 0 %}{{email_body}}{% endif %}'
      from: '{{email_from}}'
      to: '{{email_to}}'

---
chain:
  -
    name: 'query_mssql'
    ref: 'mssql.execute.query'
    parameters:
      query_string: '{{query_string}}'
      params: '{{params}}'
      database: '{{database}}'
    on-success: 'email_results'
  -
    name: 'email_results'
    ref: 'core.sendmail'
    parameters:
      to: '{{email_to}}'
      from: '{{email_from}}'
      subject: '{{email_subject}}'
      body: '{% if query_mssql.result.output_files | length > 0 %}{{email_body}}{% endif %}'
      attachments: '{{query_mssql.result.output_files | join(",")}}'
      send_empty_body: False

Update parameter order to group related static and dynamic values
Update parameter order to group related static and dynamic values
