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
Related
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.
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.
I want to find only failed user details, but the below query is giving duplicate records. I am not able to find a proper solution.
To find failed job details I'm using the below query:
select * from executionlog e
join catalog c on e.reportid = c.itemid
where c.name like '%reportname%'
and timestart>= '2013-04-15 09:00:00.000'
and status <> 'rsSuccess'
However, the above query is giving duplicate values for a particular report.
How can I get unique details?
Note: we cannot apply distinct or group by because the table contains columns of ntext and image data types
If you want only "failed user details" then don't select the ntext or image columns at all. That way you can do a DISTINCT normally:
SELECT DISTINCT
--Parameters,
--Content,
--Property,
--Parameter,
InstanceName, ReportID, UserName, RequestType, Format, TimeStart, TimeEnd,
TimeDataRetrieval, TimeProcessing, TimeRendering, Source, Status, ByteCount,
[RowCount], ItemID, Path, Name, ParentID, Type, Intermediate, SnapshotDataID,
LinkSourceID, Description, Hidden, CreatedByID, CreationDate, ModifiedByID,
ModifiedDate, MimeType, SnapshotLimit, PolicyID, PolicyRoot, ExecutionFlag,
ExecutionTime
FROM executionlog e
JOIN catalog c ON e.reportid = c.itemid
WHERE c.name LIKE '%reportname%'
AND timestart>= '2013-04-15 09:00:00.000'
AND status <> 'rsSuccess'
You can even trim many more columns. Note that doing SELECT * is a bad practice for many cases anyway.
If you're interested in the corresponding ntext and/or image values you can always join the catalog against the above subquery again.
I have a SQL Server 2008-R2 database that I am migrating it's data to a different SQL Server 2008-R2 database. The database contain over 400 tables but I need to find all tables that contain images and documents that are saved in BLOB format and put those items into a separate database (also SQL 2008-R2).
I have used the following script to locate all tables that have either a Binary, Image, Varbinary, Varchar(MAX), nVarchar(MAX):
SELECT
OBJECT_NAME(c.id) as TableName,
c.name as ColumnName,
c.colid As ColumnOrder,
st.name as UserType,
bt.name as BaseType
FROM
dbo.syscolumns c
INNER JOIN dbo.systypes st ON st.xusertype = c.xusertype
INNER JOIN dbo.systypes bt ON bt.xusertype = c.xtype
WHERE
OBJECTPROPERTY(c.id,'ISTABLE') = 1
AND((st.name = 'nvarchar' AND c.length = 8000) OR
(st.name = 'varchar' AND c.length = 8000) OR
(st.name in('sql_variant','varbinary','binary','image')))
ORDER BY
OBJECT_NAME(c.id),
c.colid
But this only cuts the list in half, other than building SELECT Statements for each of these tables is there an easier way of finding BLOB files in this database?
Hey guys, first off all sorry, i can't login using my yahoo provider.
anyways I have this problem. Let me explain it to you, and then I'll show you a picture.
I have a access db table. It has 'report id', 'recpient id', and 'recipient name' and 'report req'. What the table "means" is that do the user using that report still require it or can we decommission it.
Here is how the data looks like (blocked out company userids and usernames):
*check the link below, I cant post pictures cuz yahoo open id provider isnt working.
So basically I need to have 3 select queries:
1) Select all the reports where for each report, ALL the users have said no to 'reportreq'. In plain English, i want a listing of all the reports that we have to decommission because no user wants it.
2) Select all the reports where the report is required, and the batchprintcopy is more then 0. This way we can see which report needs to be printed and save paper instead of printing all the reports.
3)A listing of all the reports where the reportreq field is empty. I think i can figure this one out myself.
This is using Access/VBA and the data will be exported to an excel spreadsheet. I just a simple query if it exists, OR an alogorithm to do it quickly. I just tried making a "matrix" and it took about 2 hours to populate.
https://docs.google.com/uc?id=0B2EMqbpeBpQkMTIyMzA5ZjMtMGQ3Zi00NzRmLWEyMDAtODcxYWM0ZTFmMDFk&hl=en_US
I suggest:
SELECT DISTINCT o.reportid, o.ReportReq
FROM All_Reports AS o
WHERE o.reportid Not In (SELECT reportid FROM All_Reports
WHERE reportreq <>"N" Or reportreq Is Null)
There is a problem with this query in that I note that the sample document has a value for batchprintcopies where reportreq is null, so here are three possibilities:
1 Exclude reports where reportreq is null:
SELECT reportid, SUM(batchprintcopies) FROM All_Reports
WHERE reportreq <>"N"
GROUP BY reportid
HAVING Sum(batchprintcopies)>0
2 Group By reportreq to allow for further descisions:
SELECT reportid, reportreq, Sum(batchprintcopies) AS SumOfCopies
FROM All_Reports
GROUP BY reportid, reporteeq
HAVING Sum(batchprintcopies)>0
3 Include reports where reportreq is null:
SELECT reportid, SUM(batchprintcopies) FROM All_Reports
WHERE reportreq <>"N" Or reportreq Is Null
GROUP BY reportid
HAVING Sum(batchprintcopies)>0
It is unlikely, but not impossible that a field (column) contains a zero-length string. I reckon they should be avoided.
SELECT reportid FROM All_Reports
WHERE reportreq IS NULL OR reportreq = "";
1) This query works by taking each report ID and looking for a row where someone has not marked it as "not required" (with the assumption that 'n', and 'N' are the only ways to indicate that). If it finds any rows for that report ID that are still required.
SELECT DISTINCT report_id FROM table_name AS outer
WHERE NOT EXISTS
(SELECT report_id FROM table_name
WHERE report_req NOT IN ("n","N")
AND report_id=outer.report_id);
2) This query just adds up the values of batchprintcopy on a per-report_id basis (where the report is required, same assumption as above).
SELECT report_id, SUM(batchprintcopy) FROM table_name
WHERE report_req NOT IN ("n","N")
AND batchprintcopy > 0
GROUP BY report_id;
3)
SELECT report_id FROM table_name
WHERE report_req IS NULL OR report_req = "";