How to query values from xml nodes?

后端 未结 4 1973
既然无缘
既然无缘 2020-11-28 11:57

i have a table that contains an XML column:

CREATE TABLE Batches( 
   BatchID int,
   RawXml xml 
)

The xml contains items such as:

4条回答
  •  春和景丽
    2020-11-28 12:48

    This works, been tested...

    SELECT  n.c.value('OrganizationReportReferenceIdentifier[1]','varchar(128)') AS 'OrganizationReportReferenceNumber',  
            n.c.value('(OrganizationNumber)[1]','varchar(128)') AS 'OrganizationNumber'
    FROM    Batches t
    Cross   Apply RawXML.nodes('/GrobXmlFile/Grob/ReportHeader') n(c)  
    

提交回复
热议问题