Saturday, February 4, 2012

Don't send that empty SSRS report.

Some of us has a daily or weekly process that puts some data in the tables and has some reports that report on top of these data, part of the daily process in any business it schedule report subscriptions ...

Sometime you get empty reports if the data is missing or no data for that day and you need to filter and not to send these reports....

There's are many ways to do it...but the most easiest one is to schedule your report normally, SSRS will create a new SQL agent job with a GUID numbers and later, just edit this job, go to the steps and add your protection code.

The simplest code will check if therefore any rows or not, you can also get notified using DBMail if no data, instead of sending empty reports to your boss!!

 You can alter this step, or add a step before... Up to you.

Well I'm lazy, i'll alter this one and add a simple code to check if the table has rows or not !!
You can also use your own query based on a date and time column that you have !! to check for new data that you'll report on.

If exists (select * from tableA where Date_Column = getdate() )
Exec ...... 
Send yourself an E-mail....

Just be creative...
You can also use sp_send_dbmail  and send yourself an e-mail if it's empty.

Hope that helps..