Find where report email job is - sql-server-2008

I'm having a report (.rdl) in Visual Studio 2012. I know that this report is sent by email every day at 5AM, but I can't find the job that is doing this. I've been looking in SQL Server Agent jobs but it's not there.
I've heard the job can't be in SQL Server agent because then the pictures in the report can't be attached to the email (don't know if that's true?).
I have tried looking in Reporting Services Configuration Manager by connecting to the db, but I think it's only the service/server(?) properties there. Couldn't find any email job sending that report.
When I look at the dataset that is used for the report I can only find the source that fills it (a stored procedure), but that doesn't help me much..
Do you know where else to look to find this job? What is normal when trying to send a .rdl report email? Is it possible to do this from VS 2012?

Report Subscriptions are run through SQL Server Agent.
You can get the job names, which are GUID type strings, with a query like this against your ReportServer database:
select JobName = rs.ScheduleID
, ReportName = c.Name
from ReportSchedule rs
inner join [Catalog] c on rs.ReportID = c.ItemID
Which will give a result like:
This matched jobs that can be seen in the SQL Server Agent:
You can check the job and see what it's doing:
i.e. calling a stored procedure on the ReportServer database.
See SSRS Subscriptions and their SQL Server Agent job names for a more detailed query.

Related

Execute Report Data-driven Subscription with T-SQL

I'm trying to use the SQL agent job created by an SSRS data-driven subscription to generate a report. Another application uses a stored procedure to insert data. I would like to generate a report immediately after the data is inserted by modifying that stored procedure to execute the SQL Server Agent. My code is follows:
USE msdb EXEC sp_start_job #job_name = 'F2B1...'
This approach works perfectly when the Agent job is from a standard subscription. With a Data-driven description, the value of the LastStatus column is "pending" for a long while and then changes to "Done: 1 processed of 1 total; 1 errors". I do not see an error in the SQL Agent error log.
Is there a way to do something like this? If so, can I pass the parameters to the report or does it still execute the query defined in the data driven subscription?
Thanks!
You can also kick off a subscription by Subscription ID.
EXEC dbo.AddEvent #EventType = 'TimedSubscription', #EventData = '<YOUR SUBSCRIPTION ID HERE>'
Where the Event Data parameter is the Subscription ID of your report's subscription.
I actually haven't tried this with a Data Driven Subscription before though.

Using User!UserID in SSRS to access data in SSAS Cube

I am running SQL 2012 and I have a SSAS multidimensional cube that holds measures for our retail business. I have created an SSRS report that pulls the data from the SSAS cube. I want the user to be able to run the report and only pass the users specific store revenue, customer count, ect, on the SSRS report that they are viewing.
I have created a parameter from the cube. Under the report parameter that was created from the cube I put in under default values, specific values, this expression for the value ="[DimUserTable].[Username].[UserID].&[" + User!UserID + "]", the report will not run. It gives the error;
For more information about this error navigate to the report server on the local server machine, or enable remote errors
Query execution failed for dataset 'Revenue'. (rsErrorExecutingCommand)
Does anyone have any idea how I can accomplish getting only the users store information to show on the report they are viewing?
You only need to pass the user id to the parameter.. your query should take care of the filtering using the parameter. Something like
where [DimUserTable].[Username] = #userid
I would use the following as the default value for the userid parameter
=User!UserID.Substring(User!UserID.LastIndexOf("\")+1)
Of course, this depends on what your cube holds for userid value. If it does NOT include the domain or machine name.. use the above.. else just use =user!userid

SSRS Subscription: Send Email on Report Failure

I have an SSRS report with some pre-selected parameters.
Every once in a while, a report parameter will randomly blank itself out and the subscription won't create the file.
Is there a way I can be emailed in the event that the server can't create the report?
I faced a similar problem, I ended up by creating configuring the Database Mail and creating an Operator to notifies me when the underlying job of the subscription fails.
Configure Database Mail to send a mail through a SMTP server even gmail or outlook works.
Create an Operator, Operators are aliases for people or groups that can receive electronic notification when jobs have completed or alerts have been raised.
Identify the underlying job that runs your subscription, use this query against the ReportServer database.
SELECT
c.Name AS ReportName
, rs.ScheduleID AS JOB_NAME
FROM
dbo.Catalog c
JOIN dbo.Subscriptions s ON c.ItemID = s.Report_OID
JOIN dbo.ReportSchedule rs ON c.ItemID = rs.ReportID
AND rs.SubscriptionID = s.SubscriptionID
The JOB_NAME column will give you the name of the job.
SQL Server Agent via SSMS go to the Jobs folder look for the job and right click it to go to properties.
In the Notifications tab set the Operator created before and the condition to send the mail.

Data-driven SSRS security

Say we have a Project Status Report in SQL Server Reporting Services (SSRS 2012) that takes the Project ID as the parameter, how can we secure the report so that only team members of that project can see the result?
We have the team members for every project in a separate table.
Thanks.
You can pass the userID as a parameter to your SQL query using query parameters and assigning user id by using command User!UserID. Then inside your SQL query you can check the privileges by using your team member table and return data accordingly

what runs the subscribed report in SSRS?

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.