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.
Related
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'
I am currently trying to set up a GUI frontend for easier querying for colleagues.
I have tried researching and following instructions from various sources but still not able to make it work.
I have two lists.
1) This is the row source query for the first list(List0):
SELECT Test_Case_ID.Test_Case_Unique_ID, Test_Case_ID.Test_Case_Description
FROM Test_Case_ID
ORDER BY Test_Case_ID.[Test_Case_Description];
2) This is for the second list(List2):
SELECT Reference_ID.Reference
FROM Test_Case_ID INNER JOIN (Reference_ID INNER JOIN Test_Result
ON Reference_ID.Reference_Unique_ID = Test_Result.Reference_Unique_ID)
ON Test_Case_ID.Test_Case_Unique_ID = Test_Result.Test_Case_Unique_ID
WHERE (((Test_Case_ID.Test_Case_Description)=[Forms]![Form1]![List0]));
I have a an event procedure for List0:
Private Sub List0_AfterUpdate()
Forms![Form1]![List2].Requery
End Sub
However, there are no outputs on List2 even after clicking on items in List0. Can I have some advice to fix it? Thank you
Firstly, check that the bound column of your list box List0 corresponds to your Test_Case_Description field.
With the form open and populated with data, you can also run a number of tests 'manually' by creating a separate query containing the SQL for your list box row source and verifying whether or not it returns any results:
select
reference_id.reference
from
test_case_id inner join
(
reference_id inner join test_result
on reference_id.reference_unique_id = test_result.reference_unique_id
)
on test_case_id.test_case_unique_id = test_result.test_case_unique_id
where
test_case_id.test_case_description = [forms]![form1]![list0]
You can also use a query with the following SQL code to test the value returned by [forms]![form1]![list0] and ensure that it returns the value that you expect for use in your selection criteria:
select
t.test_case_description,
[forms]![form1]![list0] as listboxvalue,
t.test_case_description = [forms]![form1]![list0] as testmatch
from
test_case_id t
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];
I want to accomplish a fairly simple task (I'd think).
I have one table with a shiftid (INT), shiftstart (datetime), shiftend (datetime).
I'd like to query that table, then run a query (on an entirely different database) that asks for production (which is calculated in an odd way - requiring three separate queries) using the start and end times, and store that in the original database with the shiftid and a production amount for the shift.
I've tried to do this using a Foreach Loop and a script task that builds a variable that would contain the query, but I'm continually hitting a brick wall there.
Dts.Variables("User::SQLshiftstart").Value = "SELECT value FROM[dbo].[AnalogHistory] WHERE TagName = 'Z_HISTFMZ_P2_0004' AND DateTime = '" & Dts.Variables("User::shiftstart").ToString
I keep getting an error - "Command text was not set for the command object". And googling that error doesn't push me any further down the path.
Help!
Well, I decided to go a different way instead of using a script object to build a variable. I actually created the variable in my SELECT:
SELECT (CONCAT
('SELECT CAST(value AS DECIMAL(10,4)) AS beg FROM [dbo].[AnalogHistory] WHERE TagName = ''Z_HISTDATA_P1_0007'' AND DateTime = '' ',
DateAdd(hh,-6,shiftstart),
' '' AND wwTimeZone = ''UTC'' '))
This way, I avoid having to build an intermediate script object and can directly query based on the variable name in my FOREACH loop.
We have dozens of data driven subscriptions that we run manually at the beginning of the month that use file share delivery. They point to a certain server's shared drive.
That server is going away, so we need to either manually change the data driven sql that dynamically creates a path/filename for the dozens of subscriptions,
or we were hoping we could run an update statement or something? Below is kind of what we want to change. All instances of ATLACT02 to something else.
!!!!!!!!!!
Select 'Pro Bono Section ' + RTRIM(SECT_CODE) + ' ' + RTRIM(#PERIOD) AS 'FILE_NAME',
'\ATLACT02\Crystal Reports\Reports\Section\'+RTRIM(SECT_CODE) +'\'+ RTRIM(#PERIOD) AS 'PATH',
RTRIM(SECT_CODE) AS SECT,
RTRIM(#PERIODEND) AS PERIODEND,
RTRIM(#PERIODBEGIN) AS PERIODBEGIN
From _HBL_SECT SECT
Where SECT.INACTIVE = 'N' AND (SECT_CODE BETWEEN '100' AND '699')
AND SECT_CODE NOT IN ('101','201','301','401','501','601')
in your reporting services database
select * from Subscriptions where ExtensionSettings like '%ATLACT02%'
You can use some fancy TSQL to update the XML in that field or simply use the REPLACE
UPDATE Subscription
SET ExtensionSettings = REPLACE(ExtensionSettings,'ATLACT02','NewServerName')
WHERE ExtensionSettings like '%ATLACT02%'
Obviously a bit of testing would be pretty useful before attempting to change all your datadriven subscriptions