我在编写此查询时获得了一些帮助-我有点茫然,因为我正在尝试查找所使用的查询类型或过程,并且不确定要添加到查询中的其他内容或方式改变它。
SELECT
Ds.Name as Data_Source_Name,
C2.Name AS Data_Source_Reference_Name,
C.Name AS Dependent_Item_Name,
C.Path AS Dependent_Item_Path,
ds.*
FROM
ReportServer.dbo.DataSource AS DS
INNER JOIN
ReportServer.dbo.Catalog AS C ON DS.ItemID = C.ItemID
AND DS.Link IN (SELECT ItemID
FROM ReportServer.dbo.Catalog
WHERE Type = 5) --Type 5 identifies data sources
FULL OUTER JOIN
ReportServer.dbo.Catalog C2 ON DS.Link = C2.ItemID
WHERE
C2.Type = 5
AND c.name LIKE '%mkt%'
ORDER BY
C.Path, C2.Name ASC, C.Name ASC;
请告知。
答案 0 :(得分:4)
根据我的评论,尝试一下,应该使您朝着正确的方向前进,以了解如何解析xml并在特定命令中将其清零。
您可能必须在下面的脚本中更新名称空间,并添加报告名称。
但是尝试这样的事情:
;WITH XMLNAMESPACES (DEFAULT 'http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition') --You may have to change this based on you SSRS version
SELECT
[Path],
Name,
report_xml.value( '(/Report/DataSources/DataSource/@Name)[1]', 'VARCHAR(50)' ) AS DataSource,
report_xml.value( '(/Report/DataSets/DataSet/Query/CommandText/text())[1]', 'VARCHAR(MAX)' ) AS CommandText,
report_xml.value( '(/Report/DataSets/DataSet/Query/CommandType/text())[1]', 'VARCHAR(100)' ) AS CommandType,
report_xml
FROM
(
SELECT
[Path],
Name,
[Type],
CAST( CAST( content AS VARBINARY(MAX) ) AS XML ) report_xml
FROM dbo.[Catalog]
WHERE Content IS NOT NULL
AND [Type] = 2
) x
WHERE
--use below in where clause if searching for the CommandText. Depending on how the report was developed I would just use the proc name and no brackets or schema.
--Example: if you report was developed as having [dbo].[procName] just use LIKE '%procName%' below. Because other reports could just have dbo.procName.
report_xml.value( '(/Report/DataSets/DataSet/Query/CommandText/text())[1]', 'VARCHAR(MAX)' ) LIKE '%Your Proc Name here%'
--comment out the above and uncomment below if know your report name and want to search for that specific report.
--[x].[Name] = 'The Name Of Your Report'
答案 1 :(得分:3)
您在正确的地方...当发布报告RDL时,其XML转换为图像数据类型并存储在dbo.Catalog.Content中。
如果将图像数据转换为VARBINARY(MAX),然后转换为XML,则将能够以纯文本格式读取XML。
SELECT TOP (10)
*
FROM
dbo.Catalog c
CROSS APPLY ( VALUES (CONVERT(XML, CONVERT(VARBINARY(MAX), c.Content))) ) cx (content_xml)
WHERE
c.Type = 2;
从那里开始,只需解析XML即可找出您要查找的内容。在这种情况下,您要寻找类似于以下内容的标签...
<DataSet Name="My_stored_proc">
答案 2 :(得分:0)
您要查找存储过程的名称吗?如果要查看数据库本身的位置,请选择数据库>数据库名称>可编程性>存储过程。如果您尝试使用为报表创建的查询,则需要进行存储过程或将查询类型更改为文本并将其粘贴到框中。