SQL Server Reporting Services 2005 - 如何处理空报表

发布于 2024-07-07 02:30:38 字数 526 浏览 4 评论 0原文

我想知道如果 Excel 工作表为空,是否可以不附加 Excel 工作表,如果为空,则可以在电子邮件中写一条不同的注释。

当我进入报告传送选项时,没有这样的配置。

编辑:我正在运行 SQL Server Reporting Services 2005。

下面提到的一些可能的解决方法:

MSDN:报表服务扩展

NoRows 和 NoRowsMessage 属性

我应该研究这些东西。

I was wondering if it is possible to not attach Excel sheet if it is empty, and maybe write a different comment in the email if empty.

When I go to report delivery options, there's no such configuration.

Edit: I'm running SQL Server Reporting Services 2005.

Some possible workarounds as mentioned below:

MSDN: Reporting Services Extensions

NoRows and NoRowsMessage properties

I should look into these things.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

若水微香 2024-07-14 02:30:38

我相信答案是否定的,至少不是开箱即用的。 鉴于 RS 中包含的打印交付扩展示例,编写您自己的交付扩展应该不难。

I believe the answer is no, at least not out of the box. It shouldn't be difficult to write your own delivery extension given the printing delivery extension sample included in RS.

情栀口红 2024-07-14 02:30:38

是的,我认为这是不可能的。 您可以使用表的“NoRows”属性在没有返回数据时显示一条消息,但这不会阻止附加报表。 但至少当他们打开 Excel 文件时,它可以打印出您的自定义消息,而不是空文档。

Yeah, I don't think that is possible. You could use the "NoRows" property of your table to display a message when no data is returned, but that wouldn't prevent the report from being attached. But at least when they opened the excel file it could print out your custom message instead of an empty document.

水水月牙 2024-07-14 02:30:38

在其他地方找到了这个...

我对这个问题有一个干净的解决方案,唯一的缺点是系统管理员必须创建和维护计划。 请尝试以下步骤:

  1. 为包含所有必需收件人的报告创建订阅。

  2. 将订阅设置为每周在昨天运行(即,如果今天是星期二,则选择星期一),计划从今天的日期开始,到今天的日期停止。 本质上,此计划永远不会运行。

  3. 在 SQL Management Studio 中打开新创建的作业,转到步骤并复制 SQL 行(它将如下所示: EXEC ReportServer.dbo.AddEvent @EventType='TimedSubscription', @EventData='1c2d9808- aa22-4597-6191-f152d7503fff')

  4. 使用实际计划在 SQL 中创建您自己的作业,并使用类似以下内容的内容:

IF EXISTS(SELECT your test criteria...)

BEGIN

EXEC ReportServer.dbo.AddEvent @EventType=... 等

END

Found this somewhere else...

I have a clean solution to this problem, the only down side is that a system administrator must create and maintain the schedule. Try these steps:

  1. Create a subscription for the report with all the required recipients.

  2. Set the subscription to run weekly on yesterday's day (ie if today is Tuesday, select Monday) with the schedule starting on today's date and stopping on today's date. Essentially, this schedule will never run.

  3. Open the newly created job in SQL Management Studio, go to the steps and copy the line of SQL (it will look something like this: EXEC ReportServer.dbo.AddEvent @EventType='TimedSubscription', @EventData='1c2d9808-aa22-4597-6191-f152d7503fff')

  4. Create your own job in SQL with the actual schedule and use something like:

IF EXISTS(SELECT your test criteria...)

BEGIN

EXEC ReportServer.dbo.AddEvent @EventType=... etc.

END

浪菊怪哟 2024-07-14 02:30:38

我成功地使用了数据驱动订阅和包含我的订阅者的表,数据驱动订阅查询如下所示:

SELECT * FROM REPORT_SUBSCRIBERS WHERE EXISTS (SELECT QUERY_FROM_YOUR_REPORT)

在传递设置中,收件人是包含我的电子邮件地址的数据列。
如果内部查询未返回任何行,则不会发送任何电子邮件。


为了您的目的,您可以利用“包含报告”和“评论”传送设置。
我想像这样的数据驱动订阅查询将适合您:

SELECT '[email protected]; [email protected]' AS RECIPIENTS,
CASE WHEN EXISTS (REPORT_QUERY) THEN 'TRUE' ELSE 'FALSE' END AS INCLUDE_REPORT,
CASE WHEN EXISTS (REPORT_QUERY) THEN 'The report is attached' ELSE 'There was no data in this report' END AS COMMENT

然后在配置订阅的传递设置时在适当的字段中使用这些列。

I have had success with using a Data-Driven Subscription and a table containing my subscribers, with the data-driven subscription query looking like this:

SELECT * FROM REPORT_SUBSCRIBERS WHERE EXISTS (SELECT QUERY_FROM_YOUR_REPORT)

In the delivery settings, the recipient is the data column containing my email addresses.
If the inner query returns no rows, then no emails will be sent.


For your purposes, you can take advantage of the "Include Report" and "Comment" delivery settings.
I imagine that a data-driven subscription query like this will work for you:

SELECT '[email protected]; [email protected]' AS RECIPIENTS,
CASE WHEN EXISTS (REPORT_QUERY) THEN 'TRUE' ELSE 'FALSE' END AS INCLUDE_REPORT,
CASE WHEN EXISTS (REPORT_QUERY) THEN 'The report is attached' ELSE 'There was no data in this report' END AS COMMENT

Then use those columns in the appropriate fields when configuring the delivery settings for the subscription.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文