title: adding dynamic content within body of an email (database mail) with sp_send_dbmail
body: <p>Is there a way I can add the time in the following query as the body of my email :</p>
  
  <pre><code>EXEC msdb.dbo.sp_send_dbmail
      @profile_name = 'TEST_DEV',
      @recipients = 'xxx@gmail.com',
      @query = ' select 
              Percentage = CONVERT(DECIMAL(10,1),100 - (CAST(COUNT(DISTINCT case when PD.Exception  != ' ' then PD.Id  END) as float)/CAST(COUNT(PD.Id) as float)*100))
           from 
                  DataBaseName.dbo.Product P INNER JOIN DataBaseName.dbo.LogProduct PD 
                  ON P.LogId = PD.LogId
  
                  WHERE   
                  ResponseTime &lt; GETDATE() and  RequestTime &gt; DATEADD(MINUTE, -150, GETDATE())
                  ' ,
      @subject = 'Test',
  @body = 'Please check the attached file for Providers with Many unsuccessful calls between the time xx an yy',
      @attach_query_result_as_file = 1 ;
  </code></pre>
  
  <p>In the current line </p>
  
  <pre><code>@body = 'Please check the attached file for info on calls between the time xx an yy',
  </code></pre>
  
  <p>I would like to add GetDate() in place of xx and DATEADD(MINUTE, -150, GETDATE()) in place of yy ?</p>
  
  <p>is it possible ?</p>
  
  <pre><code>declare @body nvarchar(max) 
  EXEC msdb.dbo.sp_send_dbmail
      @profile_name = 'DEV',
      @recipients = 'xxx@gmail.com',
      @query = 'exec Database.dbo.spTest' ,
      @subject = 'Test',
   select @body = 'Please check the attached file for info on calls between the time ........................',
      @attach_query_result_as_file = 1 ;
  </code></pre>
  
  <p>Would you want me to do something like this ?</p>