SSRS report subscriptions
Hello, I have a scheduled email subscription for my report sent out to the users on a regular basis. In case there is no data returned for that report, the users should not be getting the email. How do I code this? I tried to read articles on it but always find them as data-driven subscriptions. My report is not data-driven. Can someone suggest some solution?
March 10th, 2011 9:46pm

One thing you could do is inside the query used to define your data driven subscription parameters, is to join back to the dataset somehow. If the dataset returns nothing, have the join set up in such a way that it does an inner join back to your dds query and returns nothing. Another technique i've seen used is to force the data set inside the report to fail with a divide by zero error in the case of returning nothing. I'm not sure if it's the best solution, but it works
Free Windows Admin Tool Kit Click here and download it now
March 11th, 2011 12:51am

My reports are not data driven. I have a set datasource from which the data gets fed into the report.
March 11th, 2011 6:52pm

Well you could try to force the dataset to fail with a divide by zero error if no results are returned.. First take a count of the number of rows in your result set and assign to a variable. If no data is returned, that variable will = 0. You can now force the query to error, which will cause the report rendering to fail, and no email will be sent. DECLARE @resultCount int; SET @resultCount = (SELECT COUNT(*) FROM (<your query here>) q); IF (@resultCount = 0) BEGIN SELECT 1 / 0; END ELSE BEGIN <your query here> END It is a messy solution - have a look at the following thread for other alternatives. http://social.msdn.microsoft.com/forums/en-US/sqlreportingservices/thread/247af805-9d3a-4b55-b340-1702f6173d1f
Free Windows Admin Tool Kit Click here and download it now
March 12th, 2011 9:59am

Well you could try to force the dataset to fail with a divide by zero error if no results are returned.. First take a count of the number of rows in your result set and assign to a variable. If no data is returned, that variable will = 0. You can now force the query to error, which will cause the report rendering to fail, and no email will be sent. DECLARE @resultCount int; SET @resultCount = (SELECT COUNT(*) FROM (<your query here>) q); IF (@resultCount = 0) BEGIN SELECT 1 / 0; END ELSE BEGIN <your query here> END It is a messy solution - have a look at the following thread for other alternatives. http://social.msdn.microsoft.com/forums/en-US/sqlreportingservices/thread/247af805-9d3a-4b55-b340-1702f6173d1f
March 12th, 2011 9:59am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics