SSRS - Data Driven Subscription -

痴心易碎 提交于 2020-01-05 07:22:23

问题


What I'm trying to do: I have a report already created that looks for something existing in one database and not in another. 99% of the time the report comes up empty. We do not need to know when there are no results to show. I only want to know when the query returns a result.

What I've done so far: I have a the Data Source created and a table (view) created to where I can query for Subscriber information.

What I hope can be answered: Is it all possible to have this report run and email my selected Subscribers only when there is data in the output?


回答1:


I see you've already looked into Data-Driven subscriptions. You should be able to write your query in the data-driven subscription to test if the report should return results, and if not, send it to a dummy address, and only send it to your subscriber list if there will be data in it.

If you put the dummy address in your table with an IsDummy flag column, you could do something like this:

SELECT [EmailTo] 
FROM SubscriptionTable
WHERE IsDummy=0
AND (SELECT COUNT(*) FROM SomeTable)>0 --report should have results
UNION ALL
SELECT [EmailTo] 
FROM SubscriptionTable
WHERE IsDummy=1
AND (SELECT COUNT(*) FROM SomeTable)=0 --report should not have results

And that's only one way, there are probably lots of other ways that might suit your needs as well or better.



来源:https://stackoverflow.com/questions/26386281/ssrs-data-driven-subscription

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!