I want an SSRS report to send a report subscription (email or file share) based on a Data Value change in the report data set.
Let’s say 500 rows of the Newest Data in a table all have "Update Time= 9/19 1:40 pm” and then 50 minutes later that table is updated to insert 200 new rows with "Update Time=9/19 2:30pm”. The data value change in this example is the ‘Update Time’ has changed on all records. I want SSRS to be triggered at 2:30pm based on in this change in the dataset records, and then SSRS will email the new 200 records.
Can SSRS do this kind of delivery? Is “data-driven” the answer? (Doesn’t look to me like data-driven solves this problem; but perhaps I am just not understanding?). Does snapshot update achieve this? (I thought snapshots are also time driven?).
SQL Version:
Microsoft SQL Server 2016 (SP2-CU2) (KB4340355) - 13.0.5153.0 (X64)
Jun 28 2018 17:24:28
Copyright (c) Microsoft Corporation
Enterprise Edition: Core-based Licensing (64-bit) on Windows Server 2012 R2 Datacenter 6.3 <X64> (Build 9600: ) (Hypervisor)
NOTE: I will use RANK() windowing function to achieve that grouping pretty easily-- It would group everything as 1 (200) rows, 2 (500) rows, etc. I would keep only group 1, so all of the records would have a new ‘Update Time’.
https://learn.microsoft.com/en-us/sql/reporting-services/subscriptions/subscriptions-and-delivery-reporting-services?view=sql-server-2017#triggering-subscription-processing.
Triggering subscription processing
The report server uses two kinds of events to trigger subscription
processing: a time-driven event that is specified in a schedule or a
snapshot update event.
A time-driven trigger uses a report-specific schedule or a shared
schedule to specify when a subscription runs. For on-demand and cached
reports, schedules are the only trigger option.
A snapshot update event uses the scheduled update of a report snapshot
to trigger a subscription. You can define a subscription that is
triggered whenever the report is updated with new data, based on
report execution properties that are set on the report.
Processing a data-driven subscription
Data-driven subscriptions can produce many report instances that are
delivered to multiple destinations. The report layout does not vary,
but the data in a report can vary if parameter values are passed in
from a subscriber result set. Delivery options that affect how the
report is rendered and whether the report is attached or linked to the
e-mail can also vary from subscriber to subscriber when the values are
passed in from the row set.
Data-driven subscriptions can produce a large number of deliveries.
The report server creates a delivery for each row in the row set that
is returned from the subscription query.
As far as I can see, you are correct. The snapshot update method would require snapshots to be created and snapshots are only created on a schedule or manually by a user.
What might have less overhead than a datadriven subscription is to have a stored procedure that runs the simplest query to detect if any pertinent data has changed and, if so, trigger the subscription.
EXEC dbo.AddEvent #EventType = 'TimedSubscription', #EventData = '00f4ecee-891d-445f-ae81-24ef62d3fb53'
Where the Event Data is your subscription ID (copy the Edit subscription link to get the ID)
Of course you'd have to run an SSIS job to execute your stored procedure every 15 min or so but I think it's better than the data driven subscription.
Related
I'm trying to test setting up a data driven subscription that takes a parameter from the report but it wont validate the query, should I be able to do this.
SP: Select * from Table where Column = #Variable
The #Variable is called the same of the report.
This is 2017 version of reporting services
The subscription query does not allow parameters because it is meant to run on a schedule without interaction from a user.
Can anyone tell me if it is possible to view the parameter details each time a particular subscription was ran in SSRS 2008 R2?
I can see in the reportServer DB the executionLog table, but this does not record the actual Subscription that ran (we can have dozens of subscriptions per report). Also I cannot join the subscription table to the executionLog table as the only key is the ReportID.
I can find the specific subscription in the Subscription table using the description, but I need to find an audit log of changes that were made to each subscription over a period of time eg - the DataSource was changed or a paramter was changed from A to B. I know that these changes can only be done with a certain security level and each time the change needs to be saved - but can this info be pulled for specific subscriptions?
Thanks
so my question is, what runs the subscribed report in SSRS ? I mean when I subscribe to report and give it a desired time when it should run and send me the file. something does this right ? so I want to know what runs it ? is it a procedure in SQL function ? well the reason why I want to know this is that I want to run SQL update before each time this scheduled report starts.
I can just create procedure that will do the update I want before the scheduled time but, still it will be more practical to integrate it within the job itself
Short answer, these subscriptions are run as database jobs through the SQL Server Agent.
They are created with GUID type names:
The one job step will have a command like:
exec [ReportServer].dbo.AddEvent #EventType='SharedSchedule', #EventData='8df4ff30-97d3-41f7-b3ef-9ce48bfdfbfa'
You can trace these jobs/GUIDs back to the subscription and report through the ReportServer database using the Subscriptions table and its MatchData column (matches the job GUID) and the Catalog table which includes the report data (i.e. linked through the Subscriptions.Report_OID column.
You can use this information to check what's scheduled and based on this schedule your update appropriately.
I haven't tried it myself, but one option could even be to hook into the existing database jobs, but I would approach this with caution; I can't see any issues but maybe it's best not to update any system created jobs like these.
I have a report that is scheduled to be emailed out every Friday (weekly report. If the Friday falls on a holiday is there any way to make this report be emailed out on the Thursday instead, via having the holidays stored in a table or of a similar nature.
I guess the more appropriate question might be: is it possible to create a data-driven schedule in SSRS?
To be specific, all holidays would be user defined. Ideally stored in an SQL db. If the date that the report was meant to go out exists in this table than the report would be delivered a day earlier.
Reporting services cannot do that by default.
A workaround could be:
Create a table with holiday's
Create a weekly schedule for each report, setting Friday as the day to run
Create a scheduled task in SQL server agent to run on each week start, which will check if there is a holiday in this week. If it is, it will update the DaysOfWeek of the Schedule table on your report server from 32 (friday) to 16(thursday), otherwise it will set DaysOfWeek value to 32 (default)
Important: Backup before attempting any change on your report server database.
Let me specify the environment. The client has UI for entering orders in SQL Server database. A Windows Service one another machine is processing these orders from database at particular intervals. Sometimes the Windows service is stopped then orders piles up. To avoid that I have created a SQL Server Report which is run at an interval of 5mins. It checks how many orders are processed and creates a status report. What I want, if count of processed order is zero then the report be mailed to system administrator. Then he will check the machine where the service is hosted and restart the service, so that all rework is avoided. So the question is how to implement this conditional delivery of report. In short, if count is zero no report be mailed otherwise it must.
This is 4 years late, but for anyone who stumbles onto this, a Data Driven Subscription will do the trick.
In short, you can create a query that returns the recipients if there is data, or NULL if there isn't any data.
This can be done by using Data Driven Subscription, where we have to put some SQL condition query in which it return ToEmail Address if data is present then ToEmail Address will not be blank or NULL
Below are some code that will help
IF EXISTS(SELECT 1 from Table where datefield = CONVERT(varchar(13),GETDATE() -1 ,23)+' 00:00:00.000' )
Select ToEmailAddress ='abc.pqr#xyz.com'
ELSE
Select ToEmailAddress =''
It's a common problem with SSRS 2005 (not sure about 2008) - there's no easy way to stop an empty report from being sent.
Link
The solution I had to use (and yes, I know it's ugly, inefficient, and somewhat embarrassing...), is to run your search query in a stored procedure. If rows are not found, cause an error. If rows are found, re-run your query.
SELECT * FROM TABLE
IF ##RowCount = 0
BEGIN
SELECT 1/0
ELSE
SELECT * FROM TABLE
END
Returning an error will prevent the subscription from emailing the report.