I need a help with the situation below:
In my table SQLServer 2012 have a field with xml values, I would like to make a select of the data in that field and show the result in the form columns.
<row>
<ID_Cota>162986</ID_Cota>
<ID_Taxa_Plano>1000</ID_Taxa_Plano>
<ID_Plano_Venda>1020</ID_Plano_Venda>
<ID_Pessoa>18522</ID_Pessoa>
</row>
Thank you.
Best Answer
Use
CROSS APPLY
and the .nodes method of the XML data-type, eg something like this:Here are my results:
The
.nodes
method returns a resultset from XML. Use thetext()
accessor for a performance boost when querying untyped XML ( ie no XSD is associated with the XML column and the[1]
ordinal, which is a shorthand way of saying "get me the first element you find".HTH