I was studing a little about xml parsing, using examples I found here in stackoverflow but I came across a doubt. If I have something like this
DECLARE @xml xml
SET @xml =
'<?xml version="1.0" encoding="UTF-8"?>
<oo_outbound_order>
<oo_master>
<Code>123</Code>
<Name>Branan</Name>
</oo_master>
</oo_outbound_order>'
SELECT
n.value('(./Code/text())[1]','int') as CODE
, n.value('(./Name/text())[1]','Varchar(50)') as NAME
FROM @xml.nodes('/oo_outbound_order/oo_master') as a(n)
I get something like this
CODE NAME
123 Branan
but if one of the fields I want to store it as xml
<?xml version="1.0" encoding="UTF-8"?>
<oo_outbound_order>
<Active>true</Active>
<Weight>0.02</Weight>
<oo_master>
<Code>123</Code>
<Name>Branan</Name>
</oo_master>
</oo_outbound_order>
And I want to get something like this
Active Weight ColWithXML
true 0.02 <oo_master><Code>123</Code><Name>Branan</Name></oo_master>
SELECT
n.value('Active[1][not(@xsi:nil = "true")]', 'BIT') as Active
, n.value('Weight[1][not(@xsi:nil = "true")]', 'DECIMAL(29,5)') as Weight
, ??????????????????
How can I do that? Thank you