I'm using SSRS 2016. I want to find out the last time a particular report was run. Is this something I can easily query on the ReportServer database?
Thanks!
You can get this from the executionlog tables/views in the ReportServer database. By default this will have (I think) 60 days of logs. You can change this value in the ReportServer properties. I have 400 days retention so I can report on report usage.
Anyway, you can use something like this...
USE ReportServer
GO
select TOP 1
c.*
, el.*
from ExecutionLog el
join Catalog c on el.ReportID = c.ItemID
WHERE
c.[Path] = '/MyReportFolder/MyReportSubFolder'
and c.[Name] = 'MyReportName'
ORDER BY TimeStart DESC
The path =... is optional if all your report names are unique and the top 1 is there because you asked to only find the last time the report was run but you can obviously remove these limitations.
Related
I wanted the count of number of subscriptions of a report , Did a lot of research but unable to get the detail.
I did used Catalog and Execution log table , which just gives number of times report got executed but not the history of count of subscription with different parameters , Request any to provide any hint to acheive the task
ExecutionLog will return one record for every time a report was executed that is available based on your history retention.
What your looking for is the Subscription table.
SELECT
*
FROM
dbo.Catalog AS CAT
JOIN dbo.Subscriptions AS SUB
ON CAT.ItemID = SUB.Report_OID
WHERE
CAT.[Name] = 'My Report Name';
I am developing a report in Visual Studio 2013 and report requirements are:
Report should include detailed data for each provider who provides individual services to patients
Report also should include records for providers who provide group services. Thus the criteria in this set is different than the first set
Report should include both #1 in one report separated by each provider
I created #1 & # 2 reports but I am stock how to bring them together in one report where each provider gets his/her individual as well as group services reports in one nice formatted report. I have tried subreport with no avail but looking into linked report. Any thoughts/suggestion how this can be done? here is an example
Your data for both the Individual and Group Services is similar so what I would do is have one query for all data and then use grouping in a table to break it up the way you want and let SSRS do the work.
If your data isn't combined already in one query, I would UNION the two queries. You may need to add some dummy columns to match them all (for instance, your Group Services might need a column of ClientID - '' as ClientID) and another column with the type ('Group Services' as ServiceType in Group query and 'Individual Services' as ServiceType for Individual).
For your table, you would have 2 detail lines (add a second by right clicking on the line - one for Group Services with it's fields and the other for Individual Services. Use Visibility to hide them (=ServiceType ="Group Services")
Then Add Group -> Parent Grouping for ServiceType then Add Group -> Parent Group for Provider. Then just add your group totals.
Is there a way to get the last run date from the cache refresh page for a SSRS report and have that displayed on the report? I'd like the user to know when the data was last refreshed.
You can query the ReportServer database directly to accomplish this:
SELECT MAX(els.TimeEnd) AS LastCacheRefresh
FROM dbo.ExecutionLogStorage AS els
INNER JOIN dbo.Catalog AS cat ON els.ReportID = cat.ItemID
WHERE els.RequestType = 2 --Refresh Cache
AND els.Status = 'rsSuccess'
AND cat.Name = 'MyReport'
Also FYI, Microsoft does not support querying the ReportServer database directly, which means fields/schema could change in later versions of SSRS.
Sorry to contribute to old thread, but wasn't finding a lot of hits on this question, so figured I'd add this:
If you include a calculated field in your source query, it is evaluated when the query is run and records along with the rest of your data. For example:
select
field1
, getdate() as QueryDateTime
from
SQLServerTable
and you can then use that value as min/max/first in your report (by definition is the same on every record).
This has to be done by the server dishing up the data, not as a calculated field in SSRS, because those are evaluated at run time, same as now() expression, or global execution time variable.
One downside of course is that you're recording that data and storing it, then having to retrieve a bunch of redundant data when pulling it, so it's not really efficient from a purist I/O perspective. I suspect the cost of one column of a single date value is not too much to worry about in most cases.
I have a view that shows information of truck entries per with column: ENTERED (datetime). Based on that I've made a Crystal Report to display number of entries per day: simple grouped by ENTERED (by day) and summary COUNT(Entered).
The same effect can be achieved in SQL Server by command
SELECT
convert(date, ENTERED),
count(ENTERED)
FROM
View
GROUP BY
convert(date, ENTERED)
You can see the results (on left from Crystal Reports, on right from SQL Server - ignore the latest row please since the data is constantly updated for current day) - they are identical.
But now I know that there are some double-ups in the view so I need a distinct count. In Crystal it's just matter of changing the summary, in T-SQL it's
SELECT
convert(date, ENTERED),
count (distinct ENTERED)
FROM
View
GROUP BY
convert(date, ENTERED)
And here is a big surprise:
The distinct count number is different - not by much but different. Does anyone know why and how to fix it (and of course which version is right)?
OK, after a bit of research I've found that the reason behind the difference lies in.. milliseconds. Simple as that - Crystal truncates the time part of datetime to hours, minutes and seconds while SQL server keeps the whole "tail" of ms.
So while the Crystal's version is wrong, in my case I had to fix the truth (SQL statement) to match the report by
SELECT convert (date, ENTERED),
count(distinct dateadd(millisecond, -datepart(millisecond, ENTRANCE), ENTRANCE))
FROM View1
GROUP by convert (date, ENTERED)
How to do the opposite (show the correct number from SQL in Crystal) still eludes me.
not sure why it is showing different but what I would suggest is use distinct and count locally in crystal and not in query.
SELECT
date,
ENTERED
FROM
View
Use this in crystal report and then using available functions in crystal report get distinct and count values
I have a table in Report Builder that holds how many customers were served in a specific Program by specific Branch.
Branch -> Program -> Customers Served
I keep a running total of this but that is all that I need to be displayed, not the total for every record. Any thoughts?
It's not too clear what is required - have you looked at the RunningValue function, i.e. something like?
=RunningValue(Fields!CustomersServed.Value, Sum, Nothing)
Any more information such as an example dataset and what results you'd like to see would be most helpful.