クエリの結果を電子メールで送信したいのですが、正常に動作しますが、結果が null でない場合にのみ電子メールを実行する必要があります。
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 が空の場合はメールを送信しないでください