How to query XML column?



Hi I am new to XML Datatype. can someone help me to pick "Yes I am right" from the following XML. Tried many existing sources but of no use.



<Names>
<Name Id="1" Code="NM" Default="true">Yes I am right</Name>
</Names>


I tried the following code after searching many sources but I am getting an error Msg 9341, Level 16, State 1, Line 1 XQuery [FsFundObjective.ObjectiveMultiLingual.value()]: Syntax error near '[', expected a step expression.



select tablevalue('(/languages/language/@code)[1]','varchar')
from table t with(nolock)

No comments:

Post a Comment