我想通过电子邮件发送查询结果,它工作正常,但如果结果不为空,我只需要执行电子邮件。
EXEC msdb.dbo.sp_send_dbmail @profile_name='GDB Admin',
@recipients = 'joe@mail.com',
@subject = 'GDB Warning - THIS IS A TEST',
@body ='Key',
@query = 'select clientkey as apikey, ImportDate from
QueryDData.dbo.QueryData where clientkey not in(''blablablabla'')'
因此,如果 clientkey 为空,请不要发送电子邮件