SSRS error handling - reporting-services

Is there a way to customize how SSRS reports its log? I would like SSRS to report subscription errors to a database, is there a way to do this?
Thank You

SSRS already logs the status of its subscriptions to the report server on the server that your instance of SSRS is running on. You could run the following query on your ReportServer and it will show you the last run status of the Subscription.
I've used this query in conjunction with an SSIS package to copy the report server database to create a report that sends out to various people telling them of the status of the subscriptions that exist on the report server
USE ReportServer
SELECT
CatalogParent.Name ParentName, --Folder names
Catalog.Name ReportName, --Actual rpt name
ReportCreatedByUsers.UserName ReportCreatedByUserName, --first deployed by
Catalog.CreationDate ReportCreationDate, --deployed on
ReportModifiedByUsers.UserName ReportModifiedByUserName, --last modification by
Catalog.ModifiedDate ReportModifiedDate,
CountExecution.CountStart TotalExecutions, --total number of executions since deployment
ExecutionLog.InstanceName LastExecutedInstanceName, --server excuted on
ExecutionLog.UserName LastExecutedUserName, --user name
ExecutionLog.Format LastExecutedFormat, --render format
ExecutionLog.TimeStart LastExecutedTimeStart, --start time
ExecutionLog.TimeEnd LastExecutedTimeEnd, --end time
-- These times need work, not always what you expect
ExecutionLog.TimeDataRetrieval LastExecutedTimeDataRetrieval,
ExecutionLog.TimeProcessing LastExecutedTimeProcessing,
ExecutionLog.TimeRendering LastExecutedTimeRendering,
-- end
ExecutionLog.Status LastExecutedStatus, --status of the report processing (not subscription)
ExecutionLog.ByteCount LastExecutedByteCount, -- bytes returned (just because i can)
ExecutionLog.[RowCount] LastExecutedRowCount,
SubscriptionOwner.UserName SubscriptionOwnerUserName, --subscription creator
SubscriptionModifiedByUsers.UserName SubscriptionModifiedByUserName, --subscription modifier
Subscriptions.ModifiedDate SubscriptionModifiedDate, --latest modification date
Subscriptions.Description SubscriptionDescription, --what the subscription does
Subscriptions.LastStatus SubscriptionLastStatus,
Subscriptions.LastRunTime SubscriptionLastRunTime --last time the subscription ran. this may be different to the last
-- execution time especially if report is set to cache
FROM
dbo.Catalog JOIN dbo.Catalog CatalogParent --rs catalog (all things deployed to rs)
ON Catalog.ParentID = CatalogParent.ItemID
JOIN dbo.Users ReportCreatedByUsers --all rs users
ON Catalog.CreatedByID = ReportCreatedByUsers.UserID
JOIN dbo.Users ReportModifiedByUsers
ON Catalog.ModifiedByID = ReportModifiedByUsers.UserID
LEFT JOIN (SELECT
ReportID,
MAX(TimeStart) LastTimeStart
FROM
dbo.ExecutionLog --self explanatory
GROUP BY
ReportID
) LatestExecution --gets the latest execution date rather than having a list longer than life
ON Catalog.ItemID = LatestExecution.ReportID
LEFT JOIN (SELECT
ReportID,
COUNT(TimeStart) CountStart
FROM
dbo.ExecutionLog
GROUP BY
ReportID
) CountExecution -- gets the number of executions (because we can)
ON Catalog.ItemID = CountExecution.ReportID
LEFT JOIN dbo.ExecutionLog
ON LatestExecution.ReportID = ExecutionLog.ReportID
AND LatestExecution.LastTimeStart = ExecutionLog.TimeStart
LEFT JOIN dbo.Subscriptions --subscription details
ON Catalog.ItemID = Subscriptions.Report_OID
LEFT JOIN dbo.Users SubscriptionOwner --user info
ON Subscriptions.OwnerID = SubscriptionOwner.UserID
LEFT JOIN dbo.Users SubscriptionModifiedByUsers --user info
ON Subscriptions.OwnerID = SubscriptionModifiedByUsers.UserID
ORDER BY
CatalogParent.Name,
Catalog.Name
Logging and reporting on the stack trace as in the LogFiles on the server is a little less straightforward!

SSRS have a default logging mechanism on SQL server instance being used with SSRS report. you can find the log file on the following path.
C:\Program Files\Microsoft SQL Server\MSRS11.MSSQLSERVER\Reporting Services\LogFiles
Top most file have all the reporting server logs, open that file and navigate to the end to view most recent logs.

Related

SSRS - Trying to find all User Reports tied to a Batch File / Subscriptions

I have tried various queries I have found to try and accomplish this and none of them seem to list all the batch file/subscription instances tied to a user report in SSRS. If there is already a batch file out there tied to a user report, that's what I want to use versus creating a new batch file. I have tried going through the tables in the ReportServer database and looking for records to link to try and find this information, but I have been unsuccessful. Sorry if this is a simplistic question, but I have spent a few days trying to figure this out. Thank you!
You should be able to get at all subscriptions on your report server by running the following query:
You can alter this to suit your needs
use [ReportServer]
SELECT
R.Name
, L.TimeDataRetrieval
,L.TimeProcessing
,L.TimeRendering
, L.TimeDataRetrieval+L.TimeProcessing+L.TimeRendering AS TotalTime
,L.Format
,L.[Parameters]
,L.username
,L.TimeStart
,L.TimeEnd
,l.ReportID
,DATEDIFF(SECOND,L.timestart,L.timeend) time_seconds
,r.Path
FROM dbo.ExecutionLog L
INNER JOIN dbo.Catalog R
ON L.ReportID = R.ItemID
WHERE
R.Name like 'name of your report'

SSRS Subscription Schedule Started/Completed Events

I am pretty new to SSRS and I am trying to find a way to know when scheduled report is actually started on the server, when it has completed with success of failure and if it was canceled. As of now, I am using the ReportingService2010 class API to talk to the Report Server and the only way that it seems possible to me is to make something custom that checks the schedules and fire events at these times for the started events and to scan the folder where I'm going to save the report and when a new file is added, I know that the report has been successfully created, and maybe add a Timeout event after x time.
I don't think this is a really clean approach and I'm sure that you guys might have an easier answer because I'm sure that there must be a way to do it without manually scanning everything.
I used the ListJobs() method to access all the jobs that are currently running on the server but it doesn't seem to consider when a subscription is done, because, I only get results in the ListJobs() method when I manually click on "Run Now" for a specific report on the server.
Do you guys have any idea?
Thanks a lot,
Claude
There are few tables in 'ReportServer' database to provide you most of your information. e.g Subscriptions table has column as LastStatus, it gives how many subscriptions were processed and status of reports last run. e.g 'Done: 2 processed of 2 total; 0 errors' , 'Pending' ,
sample query would be like below, this is for getting a schedule but you can check and modify as you need.
Setup a new report with this query and schedule it as per your need to give you the status.
SELECT CAT.Name
,CAT.[Path] AS ReportPath
,SUB.LastRunTime
,SCH.NextRunTime
,CONVERT(VARCHAR(10), CONVERT(datetime, SCH.NextRunTime, 1), 101) As RunDate
,right(convert(varchar(32),SCH.NextRunTime,100),8) As RunTime
,SUB.[Description]
,SUB.EventType
,SUB.LastStatus
,SUB.ModifiedDate
,SCH.Name AS ScheduleName
FROM reportserver.dbo.Subscriptions AS SUB
INNER JOIN reportserver.dbo.Users AS USR
ON SUB.OwnerID = USR.UserID
INNER JOIN reportserver.dbo.[Catalog] AS CAT
ON SUB.Report_OID = CAT.ItemID
INNER JOIN reportserver.dbo.ReportSchedule AS RS
ON SUB.Report_OID = RS.ReportID
AND SUB.SubscriptionID = RS.SubscriptionID
INNER JOIN reportserver.dbo.Schedule AS SCH
ON RS.ScheduleID = SCH.ScheduleID
--Where CONVERT(VARCHAR(10), CONVERT(datetime, SCH.NextRunTime, 1), 101)
= CONVERT(VARCHAR(10), CONVERT(datetime, getDate()+1, 1), 101)
ORDER BY USR.UserName
,CAT.[Path];

Notification that a JOB did not start in SQL Server Agent 2008

We are able to send notification regarding failure/success of a job but if a job does not start on its scheduled time can we create a script which will send a notification to my mail box saying that the "JOB did not start'?
Per documentation, below are the only cases which can be notified. So, JOB Doesn't start isn't even in the list; which means that you can't set a notification for that.
But my thinking is that, If you know that in a day you are supposed to get N email notification for N jobs, you can check that and find out which job didn't run.
When the job succeeds to notify the operator when the job completes successfully.
When the job fails to notify the operator when the job completes unsuccessfully.
When the job completes to notify the operator regardless of completion status.
SELECT DISTINCT
J.NAME AS 'JOBNAME',
MSDB.DBO.AGENT_DATETIME(RUN_DATE, RUN_TIME) AS 'RUNDATETIME'
INTO #TEMP
FROM MSDB.DBO.SYSJOBS J
INNER JOIN MSDB.DBO.SYSJOBHISTORY H
ON J.JOB_ID = H.JOB_ID
WHERE J.ENABLED = 1 --ONLY ENABLED JOBS
ORDER BY JOBNAME, RUNDATETIME DESC
IF NOT EXISTS (
SELECT * FROM #TEMP
WHERE JOBNNAME = 'JOBNAME'
AND RUNDATETIME = 'RUNDATETIME')
BEGIN
SEND AN EMAIL
END
There's no simple way to do this, but you can query the job history tables to check if the job start time has been logged. If it hasn't you can use an IF expression to send you an email.
Thanks.

CRM2011 Filtered Views and Reporting Services

I have a strange problem, I am trying to use reports within dynamics, I have created a query that runs agains the Filtered Views:
SELECT TOP 10 Activity.ActivityOn, Activity.Name, Activity.activitytypecodename, Activity.subject, Activity.owneridname, Activity.createdon FROM (
SELECT 'Project' as ActivityOn, project.new_name AS Name, activitytypecodename, subject, activity.description, activity.owneridname, activity.createdon FROM dbo.Filterednew_project project
JOIN dbo.FilteredActivityPointer activity on project.new_projectid = activity.regardingobjectid
WHERE project.new_projectid = #ProjectId AND (NOT activity.statecode = 2)) Activity ORDER BY Activity.createdon DESC
However when I try to run the report that uses this in Dynamics, no rows are returned (I am logged in as myself, with full sys admin privilages.) Yet, when I run it on SSRS (through /reports) then it returns rows. (this is also running as myself.)
Does anyone have any ideas of what is wrong? (There are no errors, it just fails to return data in dynamics.)

Get files for deployed Reports

Is it possible to get the files for a deployed reports ON SSRS 2005?
On of our developers deployed them to the Reporting Server, but didn't commited his changes to SVN. Now we are in an inconsistent state and we also can't find the files he created.
In Report Manager (usually the URL ends with /Reports or /Reports_instanceName ) You can look at the details of reports. The Edit button will allow you to download the .rdl definition files.
From
http://msdn.microsoft.com/en-us/library/ms156032(v=sql.90).aspx
In the Report Definition section, click Edit to extract a copy of the report definition. Modifications that you make locally to the report definition are not saved on the report server.
(I should have also noted, the interface and the button name change in SSRS 2008, so these instructions are specific to SSRS 2005.)
use ReportServer
go
create view vwReportDataSet_SharedDataSet_Mapping
as
select ds.itemid, ds.name as Report_DataSource,
cat.name as Shared_DataSource
from datasets ds
inner join catalog cat on ds.linkid = cat.itemid
go
create view vwSharedDataset_Usage
as
select cat.path,
cat.name,
cat.type,
ds.Report_DataSource,
ds.Shared_DataSource
from
catalog cat
left join vwReportDataSet_SharedDataSet_Mapping ds
on cat.itemid = ds.itemid
This SQL gives you your report dataset usage.
select * from vwSharedDataset_Usage
where type = 2
and path like '/SIT/%'
and name in ('Report1','Report2')