简体   繁体   English

SSRS在报告中没有数据时不发送电子邮件

[英]SSRS not to email when no data in Report

We are using SSRS 2008 R2. 我们正在使用SSRS 2008 R2。 In which have created a subscription for emailing the report but don't want to send the report when it has no data, as our subscription will run every hour. 其中已创建订阅以通过电子邮件发送报告但不希望在没有数据时发送报告,因为我们的订阅将每小时运行一次。 Please can anyone let me know that how can I prevent a blank report or a report with no data from emailing? 请任何人都可以告诉我如何防止空白报告或没有数据的报告通过电子邮件发送?

I achieved this using a stored procedure and data driven subscription. 我使用存储过程和数据驱动订阅实现了这一点。

  1. create a stored procedure that will return the subscription information needed (from address, to address, email body, etc) 创建一个存储过程,返回所需的订阅信息(从地址,地址,电子邮件正文等)
  2. Have the stored procedure check if data exists in your query 让存储过程检查查询中是否存在数据
  3. use an "if" statement to return a blank or dummy email address when no data exists. 当没有数据时,使用“if”语句返回空白或虚拟电子邮件地址。
  4. USe the stored procedure as the source for the data driven subscription. 使用存储过程作为数据驱动订阅的源。

If you are using Enterprise Edition, look into Data Driven Subscriptions . 如果您使用的是Enterprise Edition,请查看数据驱动订阅 (This is also in Developer Edition.) (这也是在Developer Edition中。)

If you are using any other edition of SQL Server then this is not possible without writing code to manipulate the subscriptions . 如果您使用的是任何其他版本的SQL Server,那么如果不编写代码来操作订阅,则无法做到这一点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM