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];
Related
I've created a report which shows all active Subscriptions on our Report Server and have currently got a table showing all the reports by name and I've also included 3 columns, one which shows you the code to Enable the subscription, one which shows you code to Disable the subscription and the last one shows code to Run the subscription immediately.
I've had a look at making these columns buttons/clickable text so a user can just hit the button/text and are able to Enable/Disable/Run subscriptions so it's not a single point of failure with myself. I've not been able to find anything yet which allows me to do this.
Does anyone know if this is possible and could provide some guidance on how this is/could be done?
Here's the SQL for the report:
SELECT
cat.Name,
cat.Path,
sub.Description,
sch.ScheduleID AS AgentJobID,
sch.LastRunTime,
CASE sch.RecurrenceType
WHEN 1 THEN 'Once'
WHEN 2 THEN 'Hourly'
WHEN 4 THEN 'Daily/Weekly'
WHEN 5 THEN 'Monthly'
END AS ScheduleFrequency,
'EXEC msdb.dbo.sp_start_job N''' + CAST(sch.ScheduleID as nvarchar(36)) + ''';' AS StartJob,
'EXEC msdb.dbo.sp_update_job #job_name = N''' + CAST(sch.ScheduleID as nvarchar(36)) + ''', #enabled = 1 ;' AS EnableJob,
'EXEC msdb.dbo.sp_update_job #job_name = N''' + CAST(sch.ScheduleID as nvarchar(36)) + ''', #enabled = 0 ;' AS DisableJob
FROM
ReportServer.dbo.Schedule sch
INNER JOIN
ReportServer.dbo.ReportSchedule rsch
ON sch.ScheduleID = rsch.ScheduleID
INNER JOIN
ReportServer.dbo.Catalog cat
ON rsch.ReportID = cat.ItemID
INNER JOIN
ReportServer.dbo.Subscriptions sub
ON rsch.SubscriptionID = sub.SubscriptionID
Example report in it's current form
I am currently attempting to do something similar myself, I hope this may help you in some way.
Currently the only workaround I have managed to achieve something along these lines is to have an image or other object with an "onclick" event that actions Go To Report. I then have a dataset in this SubReport that executes the Stored Procedure using paramaters passed into it from the parent report as required. Some images below may help clarify how I did it:
Unfortunately, it can be a bit unwieldy since it opens up a sub report that the user has to navigate back out of if they need to action multiple results.
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'
Can someone help me figure out how I can retrieve all tickets? I read online and saw that there's no API to do this yet? I also read that i can write some sql code to retrieve them?
My objective is: Check OSticket to see if the ticket with the same subject is created more than 3 times, then to basically alert me ( for now it can just be a message in Powershell that says it, as I'm scripting in PS).
For that I need to retrieve all tickets in the OSticketDB. Since I just have it locally for now, I have a sql DB setup but I don't see something along the lines of ost_tickets? Not sure how I can retrieve tickets that have been duplicates from same subject.
I'm not sure I understand your question correctly. But here is SQL query, that will return all tickets, where subject has occurred more than 3 times.
SELECT
cdata.ticket_id,
cdata.subject,
ticket.number,
subjectstable.subjectcount
FROM
osticketdb.ost_ticket AS ticket
INNER JOIN osticketdb.ost_ticket__cdata AS cdata ON ticket.ticket_id = cdata.ticket_id
INNER JOIN
(SELECT subject, COUNT(*) as subjectcount FROM osticketdb.ost_ticket__cdata GROUP BY subject) AS subjectstable
ON subjectstable.subject = cdata.subject
WHERE subjectstable.subjectcount > 3
I am trying to set up an sms appointment reminder for client appointments. I use the cms opemEMR. But there do not seem to be a appointment reminder function installed, and no extentions for that function. So I thought it will be possible to do that by filtering out the appointment from SQLi using PHP, and then set up a cron job.
I am new to php and mySQL, and I have been re-thinking how to do it so many times, that by head spins, so I hope some one can show me the right direction.
Here is how I think it can be done:
First I need to go to the calendar table that holds all the calendar events(1), and find the client appointments(2). Then I need to filter the appointments, that scheduled between 24 - 25 hours in advanced(3) (I will then tell the cron job to run every hour).
Then I will need to grab the client id(4) and the time of the appointment.
I will now have client ids on all client, I need to send reminders to.
Second I need to go to the patient data table(5), to grab the phone number(6) from the client ids(7) I just extracted.
I guess, I can then put this data in to another table, from where I can fetch it when running my sms-reminder.
This is a way, I believe would work, but I am no sure how to do it. Hope some one can show me.
Hope it makes sense and that the images help.
Reg.
Lars
Check this query:
SELECT e.pc_pid, e.pc_eventDate, e.pc_startTime,p.phone_cell FROM opememr_postcalendar_events e
LEFT JOIN patient_data p ON p.id = e.pc_pid
WHERE e.pc_Title = 'Office Visit' AND e.pc_eventDate BETWEEN DATE( DATE_SUB( NOW() , INTERVAL 1 DAY ) ) AND DATE ( NOW() )
ORDER BY e.pc_eventDate, e.pc_startTime;
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.