sql-serverreporting-services

Preventing Blank SSRS Reports from Emailing without Enterprise Edition (No Data-Driven Option)


I have been looking into this all day, and haven't found an answer that is either viable, or simple enough to implement.

I have several reports built in SSRS that I have emailed to myself on a daily basis. They run a stored proc that yields results, which are then sometimes filtered down more using visibility functions in the report, or are compared to other stored proc results.

What I am having trouble with is that sometimes, after all of the filters (either in Stored Proc, or after filtering by report), there is no data, and I get a 'blank' report with a header and nothing else. I am trying to eliminate these. However, I cannot do Data-Driven subscriptions because I don't have Enterprise edition of SQL Server. And nearly every answer I have found to prevent these blank reports involves doing that. Is there another way without Data Driven to do this? TIA!


Solution

  • Instead of the report triggering the Stored Procedure, you can have your stored procedure run on a schedule and then trigger your report subscription (if there are records).

    You already have most of it done.

    You just need to

    1. END your subscription so it no longer runs automatically
    2. Add logic to check for records for your report - DECLARE @CHECK AS INT = (SELECT COUNT(*) FROM <REPORT QUERY>)
    3. Then IF @CHECK > 0, trigger your current subscription with:

      EXEC dbo.AddEvent @EventType = 'TimedSubscription', @EventData = 'xxx';

    replacing the xxx with your report subscriptions ID (found in the subscription link). The EXEC doesn't care that your subscription has an end date from step 1.

    Then you just need to schedule your stored procedure to run on your schedule. You should have a JOB AGENT on your report server that you can utilize.