I know (usually) how to export the data from XML using SQL Server and I have done so for the rest of the extract, I just can't figure out how to get the values to line up when cross applying the stuff inside the XML tags.
This works and returns the XML tag name
DECLARE @XML XML
SET @XML= '
<Export>
<CustomInformation name="Customer ID">12345</CustomInformation>
<CustomInformation name="Prepaid">0.00</CustomInformation>
<CustomInformation name="New Amount">0.00</CustomInformation>
</Export>
'
select
Description = CustomInformation.value('@name','nvarchar(max)')
from
@XML.nodes('/Export/CustomInformation') as b(CustomInformation)
This returns null
DECLARE @XML XML
SET @XML= '
<Export>
<CustomInformation name="Customer ID">12345</CustomInformation>
<CustomInformation name="Prepaid">0.00</CustomInformation>
<CustomInformation name="New Amount">0.00</CustomInformation>
</Export>
'
select
Description = CustomInformation.value('@name','nvarchar(max)')
,tire_wheel = col2.value('@Prepaid', 'money')
from
@XML.nodes('/Export/CustomInformation') as b(CustomInformation)
cross apply b.CustomInformation.nodes('CustomInformation') as c(col2)
How do I get the data to line up to the tag name?