I am scheduling some reports by using data driven subscription in SSRS 2008 R2.
Regardless of whether the generated report is empty or not, reports are still sent to recipients. This has been a common problem for long time, and honestly, the suggestions I have seen on the forums did not quite work out.
One of the suggestions, I tried, was that I have created a hidden parameter and set it to a field on the main dataset in default values tab. It throws error if the report is empty and report is generated if there is some data to show in report designer. However, when I schedule this report, it asks me to provide default value and I cannot finish scheduler wizard without providing it. If I provide any default value, the empty reports are still sent. But unlike this, an error is supposed to be thrown for empty reports and they should not be sent.
has anyone used this method before? if so, could you tell me what I am missing here please?
I was just wondering whether you guys have an ideal solution for this issue.
Many thanks for your help.
Regards
A standard subscription consists of static values that cannot be varied during subscription processing. Data-driven subscriptions get subscription information at run time by querying an external data source that provides values used to specify a recipient, report parameters, or application format.
A data-driven subscription provides a way to use dynamic subscription data that is retrieved from an external data source at run time. A data-driven subscription can also use static text and default values that you specify when the subscription is defined.
No, it's not possible to attach another file with an e-mail subscription from SSRS.
Here is my workaround: Retrieve your data via a stored procedure and put the following code in the end
IF @@ROWCOUNT = 0 RAISERROR('No data', 16, 1)
Check Russell Christopher's article and comments for more details. What surprise me is it has been 6 years and MS just can't come out a solution for this :3
Something I have found to work that is very easy to implement is to simply include an extra field in your query that divides by the row count. If the count is zero then you get a divide by zero error and the email is not sent; if the count is at least one then the report runs fine and the email goes out.
SELECT
[table].[id]
,(1/COUNT(id))
FROM [table]
WHERE [table].[id] > @Parameter
One note about this technique is that it does add some extra overhead so it may not be appropriate if you expect the possibility of very large data sets.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With