I have a SQL Server table with the following columns
ID, Attributes
Attributes data is in XML format and there are multiple values in it. I want to extract a particular value from that column. I tried the below query. But it is giving error. Could someone please help
SELECT
ID,
CAST (identityiq.spt_link.attributes AS XML).value('Attributes/Map/entry[@key="c"]/@value','nvarchar(200)')
FROM
identityiq.spt_link
WHERE
id = '8aae1d856c57c7bd016c5a0e16d00267'
XML data inside Attributes column
<Attributes>
<Map>
<entry key="Privileged"/>
<entry key="Service"/>
<entry key="c" value="US"/>
</Map>
</Attributes>
Error
Msg 2389, Level 16, State 1, Line 10
XQuery [value()]: 'value()' requires a singleton (or empty sequence), found operand of type 'xdt:untypedAtomic *'
attributeswill not match<Attributes>.