Jam*_*ins 8 ssrs sql-server-2008-r2
旧 SSRS 上的内务管理,这个特定的服务器是 2008R2。
我有下面的查询,它为我提供了所有报告的名称、位置、创建和修改概述。我还想至少包含“连接字符串”,如果可能的话,还想从数据源属性中包含一些其他详细信息。但是我在 ReportServer 中找不到它。我见过人们使用 PowerShell 将其从 SSRS Web 服务中删除,我希望找到一个 T-SQL 解决方案。
如何使用 SQL 查询显示数据源详细信息?
--List all the reports on SSRS via "ReportServer" database
USE [ReportServer]
GO
SELECT Name
--, [ItemID] --Primary key
, [Path]
, [Description]
--, [CreatedByID] --need link to get anything usable from here
, Created.UserName as CreatedByUser
, [CreationDate]
--, [ModifiedByID] --need link to get anything usable from here
, Modified.UserName as ModifiedByUser
, [ModifiedDate]
FROM [dbo].[Catalog]
left join (select [UserID]
, [UserName]
from [dbo].[Users]) as Created
on Catalog.CreatedByID = Created.UserID
left join (select [UserID]
, [UserName]
from [dbo].[Users]) as Modified
on Catalog.ModifiedByID = Modified.UserID
WHERE [Type] = 2 -- value per foundation Source http://sqlsrv4living.blogspot.com/2014/01/ssrs-get-list-of-all-reports-using.html
ORDER BY [Path], Name
Run Code Online (Sandbox Code Playgroud)
从 ReportServer 获取 SSRS 数据源
我还想至少包括“连接字符串”
如何使用 SQL 查询显示数据源详细信息?
-- Transact-SQL script to get connection string of all SSRS Shared Datasources.
/*
Let's say you want to move a database to an other SQL Server, but which of the SSRS Shared Datasources uses this database and must be changed afterwards?
With this Transact-SQL query for ReportServer database you get the connection string of all Shared Datasources,
to document the usage or to search for a specific server/database.
Please remark: Querying the ReportServer database directly is not a supported way.
Works with SSRS 2005 and higher version ReportServer databases.
Requieres select rights on the "Catalog" table in ReportServer database.
*/
-- Connection strings of all SSRS Shared Datasources
;WITH XMLNAMESPACES -- XML namespace def must be the first in with clause.
(DEFAULT 'http://schemas.microsoft.com/sqlserver/reporting/2006/03/reportdatasource'
,'http://schemas.microsoft.com/SQLServer/reporting/reportdesigner'
AS rd)
,SDS AS
(SELECT SDS.name AS SharedDsName
,SDS.[Path]
,CONVERT(xml, CONVERT(varbinary(max), content)) AS DEF
FROM dbo.[Catalog] AS SDS
WHERE SDS.Type = 5) -- 5 = Shared Datasource
SELECT CON.[Path]
,CON.SharedDsName
,CON.ConnString
FROM
(SELECT SDS.[Path]
,SDS.SharedDsName
,DSN.value('ConnectString[1]', 'varchar(150)') AS ConnString
FROM SDS
CROSS APPLY
SDS.DEF.nodes('/DataSourceDefinition') AS R(DSN)
) AS CON
-- Optional filter:
-- WHERE CON.ConnString LIKE '%Initial Catalog%=%TFS%'
ORDER BY CON.[Path]
,CON.SharedDsName;
Run Code Online (Sandbox Code Playgroud)
这是使用 TSQL 添加数据源名称的查询:
USE [ReportServer]
GO
SELECT CATALOG.NAME
,CATALOG.[Path]
,DataSource.NAME datasource
,CATALOG.[Description]
,Created.UserName AS CreatedByUser
,CATALOG.[CreationDate]
,Modified.UserName AS ModifiedByUser
,CATALOG.[ModifiedDate]
FROM [dbo].[Catalog]
LEFT JOIN (
SELECT [UserID]
,[UserName]
FROM [dbo].[Users]
) AS Created ON CATALOG.CreatedByID = Created.UserID
LEFT JOIN (
SELECT [UserID]
,[UserName]
FROM [dbo].[Users]
) AS Modified ON CATALOG.ModifiedByID = Modified.UserID
JOIN DataSource ON CATALOG.ItemID = DataSource.ItemID
JOIN CATALOG cat1 ON DataSource.Link = cat1.ItemID
WHERE CATALOG.[Type] = 2
ORDER BY [Path]
,NAME
Run Code Online (Sandbox Code Playgroud)
你不能。
当您将数据源和报告定义上传到报告服务器时,它会将它们的信息存储在 dbo.Catalog 表中,您可以使用 Convert(Xml, Convert(Varbinary(Max), Content)) 看到该表,因为它是 XML,您可以使用 XPath拉出你感兴趣的领域。
一旦您修改了 SSRS Web GUI 上的任何内容,问题就会真正开始。
如果您更改共享数据源中的连接字符串,或修改报表的数据源,那么 SSRS 将保留目录条目原样,而是将条目添加到 dbo.DataSource 表,并使用加密的 ConnectionString 保存更新的内容。
虽然您不能在这里解密它,但您可以提取一些连接字符串,然后标记过时的;但我一直无法找到它如何存储旧/新内容之间的链接。
之前在 Ask SSC 上也讨论过这一点,他们得出了基本相同的结论https://ask.sqlservercentral.com/questions/20328/decrypting-datasources-in-ssrs.html
当他们讨论相同的http://www.sqlservercentral.com/Forums/Topic1312030-150-1.aspx时,有一组部分脚本用于在 SSC 本身上调用 Web API 和 WMI
我鼓励您翻转问题并尝试提出 PowerShell 解决方案,因为随着 SQL Server 的复杂性不断增加,尝试在 T-SQL 中执行所有操作已不再可行。
| 归档时间: |
|
| 查看次数: |
29213 次 |
| 最近记录: |