我想从<AutoRefresh>0</AutoRefresh>
表中提取[ReportServer].[dbo].[Catalog]
的值(作为INT)。我知道我可以使用SUBSTRING / CHARINDEX进行一些字符串操作,但我最好使用适当的XML来提取它。
可以在此处找到XML的示例(一旦转换):
有人可以帮忙吗?
以下是将列从VARBINARY获取到XML的代码:
SELECT TOP 13 C.ItemID
,C.NAME AS [ReportName]
,CONVERT(XML, CONVERT(VARCHAR(MAX), CONVERT(VARBINARY(MAX), C.CONTENT)))
AS [ReportDeffinitionXML]
FROM [ReportServer].[dbo].[Catalog] AS C WITH (NOLOCK)
WHERE C.Type = 2
答案 0 :(得分:0)
解决方案由MS员工Shrek Li在以下链接中提供:
请注意,需要引用您的相关XML方案:
WITH xmlnamespaces(DEFAULT 'http://schemas.microsoft.com/sqlserver/reporting/2010/01/reportdefinition'),CTE AS(SELECT
TOP 50
C.ItemID,
C.Name AS [ReportName],
CONVERT(XML, CONVERT(VARCHAR(MAX), CONVERT(VARBINARY(MAX), C.CONTENT))) AS [ReportDeffinitionXML] FROM [ReportServer].[dbo].[Catalog] AS C WHERE
C.Type = 2) SELECT ItemID, [ReportName], [ReportDeffinitionXML], ReportDeffinitionXML].value('(/Report/AutoRefresh)[1]', 'int' ) AS [AutoRefreshValue] FROM CTE