If you put the reportmanager in listview you can see who deployed which report and when.
Can I retrieve this information somewhere and store it in a table for analysis?
I cannot seem to find how to do this, I did look through views and the internet but nothing to be found...
Any clues? Or is this not possible?
Grtz H.
You can query the ReportServer database tables to get this information.
Try something like:
select reportPath = r.Path
, report = r.Name
, created = r.CreationDate
, createdBy = c.UserName
, modified = r.ModifiedDate
, modifiedBy = m.UserName
from Catalog r -- report
inner join Users c on r.CreatedByID = c.UserID -- created
inner join Users m on r.ModifiedByID = m.UserID -- modified
where r.Type = 2 -- report catalog items only
Which returns information on all reports on the server, with created time/user and modified time/user.
You can filter by the datetime values as required.
Related
I read that all Reports from SSRS are stored as RDL (Report definition) on the Reportserver database.
Question: How can I see all create parameters for a report in this database? I want to find Reports with particual parameters.
I check already the Reportserver database but I did not find any table with a particul report and the used parameters.
The parameters are listed in the Parameter column of the Catalog table (ReportServer.dbo.Catalog)
The parameters are stored as XML so you cannot read them directly.
The following code will return reports with their parameter names, the parameter's label and its datatype.
SELECT
Cat.ItemID, cat.[Path], cat.Name
, p.*
FROM ReportServer.dbo.Catalog cat
JOIN (
SELECT ReportID = ItemID
,ParameterName = params.value('(Name/text())[1]', 'varchar(100)')
,Prompt = params.value('(Prompt/text())[1]', 'nvarchar(100)')
,DataType = params.value('(Type/text())[1]', 'varchar(100)')
FROM (
SELECT C.ItemID, C.Name,CONVERT(XML,C.Parameter) AS ParameterXML
FROM ReportServer.dbo.Catalog C
WHERE C.Content is not null
AND C.Type = 2
) a
cross apply ParameterXML.nodes('//Parameters/Parameter') q (params)
) p
on cat.ItemID = p.ReportID
I have an task of getting the user reconciliation where we have around 50 SQL servers, I need to take the list of database users from all the SQL servers in one place and mail it to team. Any ideas will be helpful and I have SCOM server also.
I don't know any quick or fancy way, but you could do:
;with ServerPermsAndRoles as
(
select
spr.name as principal_name,
spr.type_desc as principal_type,
spm.permission_name collate SQL_Latin1_General_CP1_CI_AS as security_entity,
'permission' as security_type,
spm.state_desc
from sys.server_principals spr
inner join sys.server_permissions spm
on spr.principal_id = spm.grantee_principal_id
where spr.type in ('s', 'u')
union all
select
sp.name as principal_name,
sp.type_desc as principal_type,
spr.name as security_entity,
'role membership' as security_type,
null as state_desc
from sys.server_principals sp
inner join sys.server_role_members srm
on sp.principal_id = srm.member_principal_id
inner join sys.server_principals spr
on srm.role_principal_id = spr.principal_id
where sp.type in ('s', 'u')
)
select *
from ServerPermsAndRoles
order by principal_name
https://msdn.microsoft.com/en-us/library/ms187328.aspx
On each of the servers, and stuff the results in a single Excel spreadsheet - then using Excel, filter only unique entries.
I was running this query for the last 6 months with no problems on several servers, but today got an error?
error_message: Database query failed: Column 'account_id' in field list is ambiguous
Column account_id is ambiguous?
$sql_query = "SELECT pricenotifier_criteria.criteria_id , pricenotifier_criteria.`event_id` , pricenotifier_criteria.`ticket_id` , pricenotifier_criteria.`criteria` ,pricenotifier_criteria.account_id ,seller_ids.user_id,seller_ids.seller_id
FROM pricenotifier_criteria
INNER JOIN seller_ids
ON ( pricenotifier_criteria.account_id = seller_ids.account_id )
INNER JOIN pricenotifier_users
ON (pricenotifier_criteria.user_id = pricenotifier_users.user_id )
INNER JOIN pricenotifier_pricing_table
ON ( pricenotifier_users.pricing_id = pricenotifier_pricing_table.pricing_id )
WHERE status=1 AND pricenotifier_pricing_table.processing_time = 15
AND pricenotifier_criteria.user_id = 339
ORDER BY pricenotifier_criteria.event_id
LIMIT 2000
OFFSET 0";
I have tried to run this query in sql in phpmyadmin but no error came there ? if i run this via php than i got that error
APOLOGY TO BE MADE
I am really sorry in the page where i was running this query i had called another page where other programmer didnt mentioned table prefrix that's why we got this error but all of the guys who replied was right so everyone has almost true answer about (why ambigius error comes). I posted it here because i was sure my query has nothing ambigious and i was right but the other file was running some query and had that error.
Cleaner version of the same thing...
SELECT c.criteria_id
, c.event_id
, c.ticket_id
, c.criteria
, c.account_id
, s.user_id
, s.seller_id
FROM pricenotifier_criteria c
JOIN seller_ids s
ON s.account_id = c.account_id
JOIN pricenotifier_users u
ON u.user_id = c.user_id
JOIN pricenotifier_pricing_table g
ON g.pricing_id = u.pricing_id
WHERE status = 1
AND g.processing_time = 15
AND c.user_id = 339
ORDER
BY c.event_id
LIMIT 2000;
I bet your php code just selects account_id without table prefix pricenotifier_criteria or seller_ids. Since both tables contain a field account_id this would be ambiguous without table prefixes.
This error :
error_message: Database query failed: Column 'account_id' in field list is ambiguous
means that account_id is the field of 2 or more tables. As an example :
SELECT account_id, other_things
FROM table_account
INNER JOIN table_account2 ON (table_account.account_id = table_account2.account_id)
account_id is the field of 2 tables : table_account and table_account2. Then, this is ambiguous, because from which table will the account_id supposed to be selected ?
As #strawberry states, the only field that can be ambiguous is status in the query you showed us. If you have really this problem, make sure you prefix all your fields in your query like this : table.field_name. Then, this will avoid this kind of error.
There are methods to create, update and delete subscriptions, get subscription properties in SSRS reporting services but i didn't find a method that tells subscription last run time and next send time?
The secret is that the next run time is stored in the MSDB job.
SELECT
c.Name AS ReportName
, rs.ScheduleID AS JOB_NAME
, s.[Description]
, s.LastStatus
, s.LastRunTime
,NextScheduledRun = CONVERT(DATETIME,LEFT(CAST(SC.next_run_date AS VARCHAR(255)),4)+'-'+SUBSTRING(CAST(SC.next_run_date AS VARCHAR(255)),5,2)+'-'+RIGHT(CAST(SC.next_run_date AS VARCHAR(255)),2)+ ' '+
LEFT((RIGHT('0'+CAST(SC.next_run_time AS VARCHAR(6)),6)),2)+':'+SUBSTRING((RIGHT('0'+CAST(SC.next_run_time AS VARCHAR(6)),6)),3,2)+':'+RIGHT(SC.next_run_time,2))
,J.enabled
FROM
ReportServer..[Catalog] c
JOIN ReportServer..Subscriptions s ON c.ItemID = s.Report_OID
JOIN ReportServer..ReportSchedule rs ON c.ItemID = rs.ReportID
AND rs.SubscriptionID = s.SubscriptionID
JOIN msdb..sysjobs J
ON LTRIM(RTRIM(rs.ScheduleID)) = J.name
JOIN msdb..sysjobschedules AS SC
ON SC.job_id = J.job_id
I can tell you how to find last run time, but not next run time:
One way you can do this is to utilize a SQL query against the Report Server database.
In the Report Server, you can query the "Subscriptions" table. There is a column in there for "Last Run Time."
Run the query below against the SQL Report Server database to see what I am talking about.
You can utilize the value in the "Last Run Time" column.
/****** Script for SelectTopNRows command from SSMS ******/
SELECT [SubscriptionID]
,[OwnerID]
,[Report_OID]
,[Locale]
,[InactiveFlags]
,[ExtensionSettings]
,[ModifiedByID]
,[ModifiedDate]
,[Description]
,[LastStatus]
,[EventType]
,[MatchData]
,[LastRunTime]
,[Parameters]
,[DataSettings]
,[DeliveryExtension]
,[Version]
,[ReportZone]
FROM [ReportServer].[dbo].[Subscriptions]
I'm using SQL Server 2008 Express
All of the select statments are fine. Now I have this one:
SELECT
ORG.id, ORG.img, ORG.name, ORG.city, ORG.address,
ORG.zip, ORG.telephone, ORG.telephone2,
ORG.fax, ORG.email, ORG.vaname, ORG.vanumber,
ORG.yor_photo, ORG.commission,
Clients.id AS yor_id, Clients.prefix,
Clients.fname, Clients.lname, Clients.phone,
Clients.pelephone, Clients.email, Clients.pid,
ORG.adddate, ORG.note
FROM Org
LEFT OUTER JOIN
(select * from Clients where yor = 1) as Clients ON Clients.company = ORG.id
WHERE ORG.id=" & ORGID
It is not working, I get error "invalid object name"
If I add the DBNAME.DBO in front of the table name it works
The problem is that i don't want to change that on every project
Why is it not working?
UPDATE
the problem is not with the db name, the problem is with the AS yor_id in the select statment.
if i remove it the record retrieved is not full with all the data but if i write it the data is full but yor_id is empty
UPDATE
NEVER MIND, my bad! id column was corupted
Before that query you need to write
use DBNAME
in order to switch to your dbname.
Probably you are running that query on master database, so just do this and should work:
use DBNAME
SELECT
ORG.id, ORG.img, ORG.name, ORG.city, ORG.address,
ORG.zip, ORG.telephone, ORG.telephone2,
ORG.fax, ORG.email, ORG.vaname, ORG.vanumber,
ORG.yor_photo, ORG.commission,
Clients.id AS yor_id, Clients.prefix,
Clients.fname, Clients.lname, Clients.phone,
Clients.pelephone, Clients.email, Clients.pid,
ORG.adddate, ORG.note
FROM Org
LEFT OUTER JOIN
(select * from Clients where yor = 1) as Clients ON Clients.company = ORG.id
WHERE ORG.id=" & ORGID