我有以下预定的工作-
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 <> 0 and B.QTYUNCMTBASE = 0'
哪个工作正常,但我想包含一个 IF 语句,它只在没有结果的情况下执行。
谢谢