Most likely, you need something like this:
SELECT Top 1000
ID,
MonthDate = XCol.value('(MonthDate)[1]', 'DATETIME'),
[Value] = XCol.value('(Value)[1]', 'FLOAT')
FROM
@ngTest
CROSS APPLY
[xmlContent].nodes('/MonthlyMedianResults/MonthlyAmount') AS XTbl(XCol)
The .nodes()
call creates a "virtual" table (XTbl
) with a single XML column (XCol
), where each row represents the XML fragment of each <MonthlyAmount>
node (and you must include a AS table-alias(column-alias)
to your CROSS APPLY
section so you can refer to this virtual table in your query).
You need to apply the XQuery .value()
to that virtual table to fetch the values from this virtual table or XML fragments.