title: sp_send_dbmail scheduled job execute only IF results <> 0
body: <p>I have the follow scheduled job -</p>
  
  <pre><code>Execute as login = 'sa'
  EXEC msdb.dbo.sp_send_dbmail
  @profile_name = 'SQL Mail Profile',
  @recipients = 'Tania.Mofflin@fuelfix.com.au',
  @subject = 'Wennsoft Service Management - Unposted Costs',
  @body = 'Unposted Costs from Closed POs:
          ',
  @execute_query_database = 'FPLL',
  @query = 'Select A.Service_Call_ID as "Service Call", A.Reference_TRX_Number as "Reference Number", A.WS_Committed_Cost as "Committed Cost"
              from SV000810 A LEFT JOIN POP10110 B on A.Reference_TRX_Number = B.PONUMBER and A.SEQNUMBR = B.ORD
              where A.WS_Committed_Cost &lt;&gt; 0 and B.QTYUNCMTBASE = 0'
  </code></pre>
  
  <p>Which works fine but I would like to include an IF statement where it only executes if there are no results.</p>
  
  <p>Thankyou</p>