Sql server 2008 根据条件以电子邮件形式发送查询结果
我想通过电子邮件发送查询结果,它工作正常,但我只需要在结果不为空时执行电子邮件Sql server 2008 根据条件以电子邮件形式发送查询结果,sql-server-2008,email,Sql Server 2008,Email,我想通过电子邮件发送查询结果,它工作正常,但我只需要在结果不为空时执行电子邮件 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 f
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为空,则不要发送电子邮件确定首先执行查询并将结果分配给变量,如果变量不为空,则执行上述电子邮件过程