【发布时间】:2016-08-23 14:18:00
【问题描述】:
我想从存储到 SQL Server 数据库表中的 XML 中读取一个属性。
我确认该列具有XML 数据类型。
我使用此查询来读取属性,但结果始终为 NULL 值。我不明白为什么。我在这里找到的所有示例都证实我做得完全正确。
SELECT
SDMPackageDigest.value('(//DesiredConfigurationDigest/SoftwareUpdateBundle/Annotation/DisplayName/@Text)[1]', 'NVARCHAR(256)')
FROM
v_UpdateInfo
这是我使用的 XML 的摘录。
<DesiredConfigurationDigest xmlns="http://schemas.microsoft.com/SystemsCenterConfigurationManager/2009/07/10/DesiredConfiguration">
<SoftwareUpdateBundle AuthoringScopeId="Site_28E438B4-CB2F-43A2-AD6B-5A993F805BCB" LogicalName="SUM_4ca07bc3-8c95-4644-be17-040a3964a02a" Version="201">
<Annotation xmlns="http://schemas.microsoft.com/SystemsCenterConfigurationManager/2009/06/14/Rules">
<DisplayName Text="Security Update for Microsoft OneNote 2010 (KB3114885) 32-Bit Edition" />
<Description Text="A security vulnerability exists in Microsoft OneNote 2010 32-Bit Edition that could allow arbitrary code to run when a maliciously modified file is opened. This update resolves that vulnerability." />
</Annotation>
...
【问题讨论】:
标签: sql-server xml xpath sql-server-2012