我想讀取存儲到SQL Server數據庫表的XML中的屬性。 我確認該列有一個XML
數據類型。如何使用xpath查詢SQL Server中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>
...
的感謝你,工作和我看到我是如何將能夠與使用它。其他XML內容。 – Monkeynaut