How to Find Last Deployment Date of SSRS Report - reporting-services

I manage our SSRS Report Server and I'm curious if there is a way to find out the last date a report was deployed to the report server.

You can use the Catalog and Users (assuming you want to know who did the change) tables to get this info.
SELECT
c.[Path], c.Name
, c.CreationDate
, cu.UserName
, c.ModifiedDate
, cm.UserName
FROM [Catalog] c
JOIN Users cu on cu.UserID = c.CreatedByID
JOIN Users cm on cm.UserID = c.ModifiedByID

Related

MS Access: Consolidate Query Data on a Form

I am putting together an MS Access database of our contacts for bidding purposes. I am at the point in the build where I would like to expand and display details of a company when you click a button. I have programmed the button to run my query and display the data on a form. The issue I am running into is: my data is being duplicated. For example:
I have a company (tbl_Company)
That company has 3 contacts (tbl_Contacts)
That company also has 2 licenses it holds (tbl_CoLic)
My query output is 6 rows of data, each contact with each license.
My end goal is to display on a form each company with all of their details, without duplicating other information. I have a total of 6 tables with different company details, each of those 6 tables can have one or more records associated with each company.
I can run separate queries to populate listboxes for each detail, but that seems cumbersome. Is there a better way? Please note this is all being done in MS Access, not SQL Server. Here is my query now:
SELECT tbl_Company.[Company Name], tbl_Contact.[First Name], tbl_Contact.[Last Name], tbl_CoLic.[License Number], tbl_CoLic.[License Code], tbl_CoLic.[Primary License], tbl_CoWA.County, tbl_CoPS.[Project Size], tbl_CoRef.District, tbl_CoRat.Rating, tbl_CoRat.Notes
FROM (((((tbl_Company INNER JOIN tbl_CoPS ON tbl_Company.[Company ID] = tbl_CoPS.[Company ID]) INNER JOIN tbl_CoRat ON tbl_Company.[Company ID] = tbl_CoRat.[Company ID]) INNER JOIN tbl_CoRef ON tbl_Company.[Company ID] = tbl_CoRef.[Company ID]) INNER JOIN tbl_CoLic ON tbl_Company.[Company ID] = tbl_CoLic.[Company ID]) INNER JOIN tbl_CoWA ON tbl_Company.[Company ID] = tbl_CoWA.[Company ID]) INNER JOIN tbl_Contact ON tbl_Company.[Company ID] = tbl_Contact.[Company ID]
WHERE (((tbl_Company.[Company ID])=[TempVars]![Details]));
Screenshot of Sample Data
Access expects forms and reports to have one record source. If you have a query or table with all the information your form needs you can just click it and access will build and manage a default form/report based on that one record source. So An access friendly approach is to give any form/report a table with everything it needs. So replicating your Database with some random suggestions and one important change -deleting the extra company name columns.
We can replicate your problem:
SELECT tbl_Company.CompanyName, tbl_Contact.FirstName, tbl_Contact.LastName, tbl_Colic.LicenseNumber, tbl_Colic.LicenseCode, tbl_Colic.PrimaryLicense, tbl_CoWA.County, tbl_CoWA.District, CompanyProjectSizes.ProjectSize, CompanyRatings.Rating, CompanyRatings.Notes
FROM ((((tbl_Company INNER JOIN tbl_Colic ON tbl_Company.CompanyID = tbl_Colic.CompanyID) INNER JOIN tbl_Contact ON tbl_Company.CompanyID = tbl_Contact.CompanyID) INNER JOIN tbl_CoWA ON tbl_Company.CompanyID = tbl_CoWA.CompanyID) INNER JOIN CompanyProjectSizes ON tbl_Company.CompanyID = CompanyProjectSizes.CompanyID) INNER JOIN CompanyRatings ON tbl_Company.CompanyID = CompanyRatings.CompanyID;
What's going on is When we combine the multiple tables into 1 we run into a problem because we have 2 license codes and each license code gets its own row. (rows in the combined table with any missing data are removed when inner joins are used. The reason we see anything is the company id for Rebel Plumbing has been added to all the formerly empty tables) The First part of your solution which sets up the next problem is to use a totals query.
SELECT tbl_Company.CompanyName, tbl_Contact.FirstName, tbl_Contact.LastName, First(tbl_Colic.LicenseNumber) AS FirstOfLicenseNumber, First(tbl_Colic.LicenseCode) AS FirstOfLicenseCode, First(tbl_Colic.PrimaryLicense) AS FirstOfPrimaryLicense, First(tbl_CoWA.County) AS FirstOfCounty, First(tbl_CoWA.District) AS FirstOfDistrict, First(CompanyRatings.Rating) AS FirstOfRating, First(CompanyRatings.Notes) AS FirstOfNotes
FROM ((((tbl_Company INNER JOIN CompanyProjectSizes ON tbl_Company.CompanyID = CompanyProjectSizes.CompanyID) INNER JOIN CompanyRatings ON tbl_Company.CompanyID = CompanyRatings.CompanyID) INNER JOIN tbl_Colic ON tbl_Company.CompanyID = tbl_Colic.CompanyID) INNER JOIN tbl_Contact ON tbl_Company.CompanyID = tbl_Contact.CompanyID) INNER JOIN tbl_CoWA ON tbl_Company.CompanyID = tbl_CoWA.CompanyID
GROUP BY tbl_Company.CompanyName, tbl_Contact.FirstName, tbl_Contact.LastName;
Now that you have the desired record source it works great in reports. However in this case When you create a form from your new record source the form quietly fails to update and edit!
What is going on is Access doesn't know how to change the tables in response to changes in the form. Most of the problem here is the total query we used. Here is a link describing when you can base a form on a query:
https://support.microsoft.com/en-us/office/use-a-query-as-the-record-source-for-a-form-or-report-e54251f3-57ca-4a7d-8e77-e498966cd41b
At this point There is not enough detail in the question to be specific about what to do. You will have to divide data entry into at least two parts in most cases as we can't put all the information into one access friendly record source. What parts will depend on user preference and how the rest of the data is structured. For the data provided I took the base tables in a form-subforms approach using the company table as the record source for the form and the contact and license tables as the subforms:

Is it possible to find related SubscriptionID from ExecutionID data in ExecutionLogStorage table?

I am trying to create a process which logs historic subscription errors into a new table.
I've tried to do this by using the data within ExecutionLogStorage, I can't however see how this data relates to a specific SubscriptionID. I can join it to ReportID but as I have multiple subscriptions per report this doesn't achieve what I need.
I have tried googling various scripts, none actually link directly to SubscriptionID.
I need to be able to record a log of successful and unsuccessful executions of subscriptions throughout the day, which will then be inserted into a new table via a SQL Server Agent Job.
Run the following query :
SELECT
sj.[name] AS [Job Name],
rs.SubscriptionID,
c.[Name] AS [Report Name],
c.[Path],
su.Description,
su.EventType,
su.LastStatus,
su.LastRunTime
FROM msdb..sysjobs AS sj
INNER JOIN ReportServer..ReportSchedule AS rs
ON sj.[name] = CAST(rs.ScheduleID AS NVARCHAR(128))
INNER JOIN ReportServer..Subscriptions AS su
ON rs.SubscriptionID = su.SubscriptionID
INNER JOIN ReportServer..[Catalog] c
ON su.Report_OID = c.ItemID
This should give you a list of all reports with subscriptions and it's history.
You should be able to base this as a guide to do what ever else you need to do.

SQL Query Report Writing

I provided the ERD showing all the Tables and their info. How would I go about writing an SQL query for this report? Let me know if any other details are needed or if the ERD is sufficient.
Thanks!
SELECT date(s.showtime) as date
, s.showtime
, c.channelnumber
, p.progname
, p.proglength
, su.suppliername
FROM program as p left join schedule as s on p.progid = s.programid
left join channel as c on s.channelid = c.channelid
left join supplier as su on p.supplierid = su.supplierid
your schedule table has many pk and your structure is not according to normalized form. better restructure it
thanks

query that will pull data where a certain document type is not found

I am writing a query for a health organization. The query is to pull patient data, where an encounter/appointment was completed but a chart note was not generated. I have the query pulling patients and their appointments; is there a way to basically say "only show the patients where 'master_im' document was not generated"?
I am using Microsoft SQL Server Management Studio.
Without seeing your table structures, etc. your could do a check to see if the master_im IS NULL.
SELECT *
FROM yourTable
WHERE appointment = 'completed'
AND master_im IS NULL
I would advise posting some additional details on your tables.
If the data is stored in separate tables, then you will want to JOIN the tables together to get the results you want.
EDIT #1 based on your comment you could do something like this:
select *
from person p
inner join appointments a
on p.enc_id = a.encid
left join patient_documents pd
on p.enc_id = pd.enc_id
where a.status = 'completed'
and pd.document_desc != 'master_im'

Group By in stored procedure error

I created this stored procedure which is basically to return a list of offices with the type of activities that happen within each office. The results i reported to reportviewer but i noticed that for each activity return it creates a table - so i can have 5 different tables each with its own activity but all happen in the same office. I want the report to be a table for each office which will contain as many activites as there are for each office. So i thought that if i grouped in my stored procedure my results will be as what i want but i am getting column error saying: "...is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause."
I am not sure how to go about that but here is my select, from, where, group by statements:
SELECT
O.OfficeId,
O.OfficeName AS Office,
HT.Description AS HearingType,
H.HearingDate AS HearingDate,
CR.Description AS Court,
CT.[Description]AS CaseType
FROM Activity H
INNER JOIN ActivityEntry HE ON H.ActivityEntryId = HE.ActivityEntryId
INNER JOIN ActivityType HT ON H.ActivityTypeId = HT.ActivityTypeId
INNER JOIN [Case] C ON H.CaseId = C.CaseId
INNER JOIN [Office] O ON HE.CreatedByOfficeId = O.OfficeId
INNER JOIN [User] U ON C.CreatedByUserId = U.UserId
LEFT OUTER JOIN CaseType CT ON C.CaseTypeId = CT.CaseTypeId
LEFT OUTER JOIN Court CR ON C.CourtId = CR.CourtId
WHERE .dbo.DateOnly(HE.HearingDate)BETWEEN #BeginDate AND #EndDate
GROUP BY
O.OfficeId,
O.OfficeName,
HT.Description
ORDER BY O.OfficeId, HT.Description
GROUP BY requires that you have some kind of an aggregate function in your list of columns - a SUM, an AVG, a COUNT. GROUP BY only makes sense in combination with an aggregate.
Otherwise, just simply order your data with an ORDER BY statement.
You aren't using any aggregate functions (on first glance anyway) so you don't need a group by clause. You can do all your ordering in the order by and then extract it into different datasets as you process it on the application side.
Example:
select ... from ... order by OfficeID, Description
This returns a single result for all offices. Now you need to parse it in code
int OfficeID=-1;
while(recordset.moveToNextRow())
{
if(currentRecord.OfficeID!=OfficeID)
{
//This is a new office, do whatever you need to do to split the data up here
OfficeID=currentRecord.OfficeID;
}
//Process the record as a part of the current office here
}
So if you were building a table on a webpage, you'd maybe end the last table and start a new table every time you hit a new office ID. There's some additional logic you'll need here, but this should give you the idea.
Note that your problem has nothing to do with using a stored procedure and everything to do with how you are selecting and processing data.
I actually realized that my problem cannot be solved through my stored procedure as mentioned from some of the members. Since i am displaying results in my report so i re-organized my report and dataset information so that there is a parent and child relationship and from the dataset my information was organized properly. I used the solutions offered from this post to help guide me: post used to help guide me.