XML Context node

0

Please login or register to vote for this query.

(click on this box to dismiss)

Electrical Engineering

Q&A for electronics and electrical engineering professionals, students, and enthusiasts

declare @X xml = '
<Notes>
  <Note>
    <Text>1</Text>
  </Note>
  <Note>
    <Text>9</Text>
  </Note>
  <Note>
    <Text>5</Text>
  </Note>
</Notes>';

select T.X.value('(./Text)[1]','varchar(500)'),
       T.X.value('(/Notes/Note/Text)[1]','varchar(500)')
from @X.nodes('/Notes/Note') as T(X);

Enter Parameters

Options:
Switch to meta site
loading Hold tight while we fetch your results