I have this XML in SQL Server
<data>
<add key="images" value="image/path/img.gif" />
<data>
I want to select the value attribute of every “add” node with key = “images”
What i have now is:
SELECT ID, Data from Items
where Data.value('(//data/add[@key="images"]/@value)[1]', 'nvarchar') Like '%img%'
Any suggestions?
What you have works fine if you just specify a size for your
nvarcharretrieved from the XML.Here I have specified
100you may set it to something more appropriate for your situation. Without the size the column will have size1.