Read XML nodes as rows in SQL Server

后端 未结 1 1180
旧巷少年郎
旧巷少年郎 2021-01-26 16:40

I have the following XML stored in a XML column of a table:



        
相关标签:
1条回答
  • 2021-01-26 17:29
    WITH XMLNAMESPACES (DEFAULT 'urn:www:bebe:de:b2b:v01')
    SELECT 
        d.p.value('./Identification[1]', 'BIGINT') AS [Identification]
        ,d.p.value('./StatusType[1]', 'NVARCHAR(100)') AS [StatusType]
        ,d.p.value('(./StatusType/@listAgencyIdentifier)[1]', 'int') AS [ListAgencyIdentifier]
        ,d.p.value('./OriginalDocument[1]', 'BIGINT') AS [OriginalDocument]
    FROM [yourtable] [t]
    CROSS APPLY [t].[yourcolumn].nodes('//PayloadResponseEvent') AS d(p)
    
    0 讨论(0)
提交回复
热议问题