Unable to get attribute value

UGGpgu

New Member
I have the following data in the column XMLData of type xml in a table -\[code\]<ns0:SR xmlns:ns0="http://Country.Regions" xmlns:Country="http://Country.Regions/Types"> <Sale Category="Heavy Load" Quantity="1" Value="http://stackoverflow.com/questions/13847908/110" /></ns0:SR>\[/code\]I am trying to get the value of Quantity from below query but getting an error -\[code\]select XmlData.value('(/SR/Sale[@Category="HeavyLoad"]/@Quantity)[1]', 'int') from Cars \[/code\]There is no element named \[code\]Category\[/code\]. I tried removing \[code\]/SR/\[/code\] still getting the same error. I am new to XQuery. Would appreciate answer containing using only \[code\].value\[/code\]. We are using SQL Server 2008
 
Back
Top