I have a Swift Message encoded with SQL query using encoding="utf-16 - I used below code:
CAST(REPLACE(CAST(Content AS VARCHAR(MAX)), 'encoding="utf-16"', '') AS XML) AS Content
Content of my XML structure looks like this:
What I want to achieve
I have a temporary table with multiple XML Files in this structure and I am trying to write a SQL query which will show me data in standard structure as a table
SELECT
DateTimeCreated,
t.value('(ApplicationHeaderBlock_Output/MessageType/text())[1]', 'varchar(100)') AS MessageType,
e.value('(SequenceC/Date_C_98A/Date/text())[1]', 'DATE') AS XDTE,
e.value('(SequenceC/Date_C_98A//Date/text())[1]', 'DATE') AS RDTE
FROM
#MTFILE
CROSS APPLY
Content.nodes('//SWIFTHeader') AS a(t)
CROSS APPLY
Content.nodes('//SWIFT_CATEGORY5_MT566') AS b(e)
DROP TABLE #MTFILE
Problem and what I want to achieve
I'm not sure how to modify my current SQL query to achieve below results from XML file, because when I'm trying to specify path from XML file you can see it is same (from screenshot structure).
My point is to achieve and see result as below:
| XDTE | RDTE |
| -------- | -------------- |
| 20210310 | 20211012 |
If somebody could please advise?

Qualifierand pivotDatebyQualifiervalues