Home > Net >  Output of XML in Resultset (T-SQL)
Output of XML in Resultset (T-SQL)

Time:12-15

I have a XML file and I want to create a SELECT statement with a specific output.

<Errors>
  <Error CheckNumber="5" Message="Within the unit there are identifier duplicates.">
    <ProductionInfo ProductionOrderNo="ABC12345" >
      <Identifier>
        <RawID>67484295</RawID>
        <UnitCode>.gEft?s</UnitCode>
        <UnitGTIN>1234567890</UnitGTIN>
      </Identifier>
      <Identifier>
        <RawID>67484297</RawID>
        <UnitCode>_Yo*IpH</UnitCode>
        <UnitGTIN>1234567890</UnitGTIN>
      </Identifier>
      <Identifier>
        <RawID>67484301</RawID>
        <UnitCode>3IBIsik</UnitCode>
        <UnitGTIN>1234567890</UnitGTIN>
      </Identifier>
      <Identifier>
        <RawID>67484318</RawID>
        <UnitCode>g&lt;*fnh6</UnitCode>
        <UnitGTIN>1234567890</UnitGTIN>
      </Identifier>
      <Identifier>
        <RawID>67484326</RawID>
        <UnitCode>LI?jTW/</UnitCode>
        <UnitGTIN>1234567890</UnitGTIN>
      </Identifier>
    </ProductionInfo>
  </Error>
  <Error CheckNumber="6" Message="The unit does not contain the required number of content information.">
    <ProductionInfo ProductionOrderNo="ABC12345" ProductionLine_InternalNo="11204">
      <Identifier>
        <RawID>67484295</RawID>
        <UnitCode>.gEft?s</UnitCode>
        <UnitGTIN>1234567890</UnitGTIN>
      </Identifier>
      <Identifier>
        <RawID>67484297</RawID>
        <UnitCode>_Yo*IpH</UnitCode>
        <UnitGTIN>1234567890</UnitGTIN>
      </Identifier>
  </ProductionInfo>
  </Error>
</Errors>

What I want is a output of two columns (ErrorMessage & Identifier). The Identifier-Column should be a character separated list of the underlying identifier.

So the output in my example should (in my example the separator is the '@') have 2 lines like:

enter image description here

  • Related