Home > Net >  Create Table from a specific column that contains XML data
Create Table from a specific column that contains XML data

Time:10-19

I am in a situation where a specific set of data that is critical to a project is stored in a SQL Server table, but the column contents are in XML.

The table is in the below format

ID DS_RowGuid PCScreenStructureVariantID Xml ToScreen FromScreen LRScreen _FlgTCF DS_RowVersion
2058 8771805B-42FC-4D43-8F37-949AFB89F372 185 XML STUFF 0 0 0 0 0x000000003F27E191

The XML column when queried returns this XML:

<IGPosEvtHallStruct Ver="1">
  <Rows>
    <Row Coord="0" Id="2768c6d4-fe88-441e-ae8a-4af0060af1bc" Legend="J" />
    <Row Coord="1" Id="96b8b07e-43cb-4812-9b3f-ce1b95e38cb2" Legend="I" />
    ---
  </Rows>
  <Columns>
    <Column Coord="0" Id="96af2fb1-3816-410c-b99d-5d9270c13b58" />
    <Column Coord="1" Id="a518716a-fabc-433c-9945-21056b7d1b96" />
    <Column Coord="2" Id="bc7fc15e-0c15-4aa1-b323-a3c6d236c904" />
    ---
  </Columns>
  <Places>
    <Place Id="296178b2-707e-4f4a-b82f-57863d23d984" RowId="2768c6d4-fe88-441e-ae8a-4af0060af1bc" ColId="96af2fb1-3816-410c-b99d-5d9270c13b58" Symbol="" Kind="Excluded" />
    <Place Id="f79f5249-711b-4d85-a1ad-f5308d431801" RowId="2768c6d4-fe88-441e-ae8a-4af0060af1bc" ColId="a518716a-fabc-433c-9945-21056b7d1b96" Symbol="" Kind="Excluded" />
    <Place Id="7b116ee5-8f1f-42b8-9eaa-2be6b29ce8d6" RowId="2768c6d4-fe88-441e-ae8a-4af0060af1bc" ColId="bc7fc15e-0c15-4aa1-b323-a3c6d236c904" Symbol="15" Kind="Included" />
    <Place Id="c90c7156-9b5f-44eb-8e59-672b4f47c248" RowId="2768c6d4-fe88-441e-ae8a-4af0060af1bc" ColId="faa1bb37-22bc-4b35-8d83-34bef01ce04a" Symbol="14" Kind="Included" />
    <Place Id="0f5995ce-47ac-453d-b37c-a04d1dcbd211" RowId="2768c6d4-fe88-441e-ae8a-4af0060af1bc" ColId="918c650b-9402-4aff-a03b-3770c60e626e" Symbol="13" Kind="Excluded" />
    <Place Id="ac1200b6-ee15-4c16-9c33-4413c9577b6c" RowId="2768c6d4-fe88-441e-ae8a-4af0060af1bc" ColId="a2d816dc-d777-4a30-8b47-e80d89ee2b7f" Symbol="12" Kind="Included" />
    <Place Id="56905ff8-369d-4f6e-8e77-0f5e2f780796" RowId="2768c6d4-fe88-441e-ae8a-4af0060af1bc" ColId="199da003-1cc5-4e6f-9c37-cbae76f6f48a" Symbol="11" Kind="Included" />
    <Place Id="e6fb8ad4-b1be-4017-a753-4cac31adf423" RowId="2768c6d4-fe88-441e-ae8a-4af0060af1bc" ColId="3f74a90e-b2bb-48a6-9a68-5e9b65a8a1c3" Symbol="10" Kind="Excluded" />
    <Place Id="fb03dc89-12a0-49cd-b978-a7e4bc355bdb" RowId="2768c6d4-fe88-441e-ae8a-4af0060af1bc" ColId="234c9999-788c-415f-88fc-b77f79e493a8" Symbol="9" Kind="Included" />
    <Place Id="35700ff7-6405-4ca8-9e74-a44da2e0d1c0" RowId="2768c6d4-fe88-441e-ae8a-4af0060af1bc" ColId="91b2e41d-9de7-49a8-b37e-5036a2c64d39" Symbol="8" Kind="Included" />
    <Place Id="f3be70c9-93a7-4824-b4b0-3d8d6bc317a5" RowId="2768c6d4-fe88-441e-ae8a-4af0060af1bc" ColId="2bb7dc3b-1355-4343-9e20-dced0778db3a" Symbol="7" Kind="Excluded" />
    <Place Id="be980a4e-49ac-4b29-8e25-92937545e088" RowId="2768c6d4-fe88-441e-ae8a-4af0060af1bc" ColId="027b3efa-81f9-456b-b13a-742bbbfed357" Symbol="6" Kind="Included" />
    <Place Id="612734a4-ead9-4fd2-9d14-d0a557464bec" RowId="2768c6d4-fe88-441e-ae8a-4af0060af1bc" ColId="c37c3c6e-ca2d-4b8a-9b67-53d8605b9ad0" Symbol="5" Kind="Included" />
    <Place Id="f753c89a-6e9a-4dbb-bf37-2110ab941293" RowId="2768c6d4-fe88-441e-ae8a-4af0060af1bc" ColId="28e1b0b4-7e92-4814-b972-42cb5e04f39e" Symbol="4" Kind="Excluded" />
    <Place Id="5d318aab-2775-4dd3-81b4-2f78f5d3bcbd" RowId="2768c6d4-fe88-441e-ae8a-4af0060af1bc" ColId="5eb3a4dc-3a1a-4f5f-8991-997533ff9912" Symbol="3" Kind="Included" />
    <Place Id="2b6c033d-9be7-41c3-ad14-60a59ef490b0" RowId="2768c6d4-fe88-441e-ae8a-4af0060af1bc" ColId="65a88ecf-6e0e-4a7c-b81e-6d2e15498011" Symbol="2" Kind="Included" />
    <Place Id="3aea20d0-ec44-48b4-8456-0d923499c299" RowId="2768c6d4-fe88-441e-ae8a-4af0060af1bc" ColId="3ddc9559-faa6-45da-97f0-c43db4e3c827" Symbol="1" Kind="Excluded" />
    <Place Id="b6ab027f-5e85-479e-86b7-17e2abfee59a" RowId="2768c6d4-fe88-441e-ae8a-4af0060af1bc" ColId="6734cca8-5391-4255-a45a-8713be965c4f" Symbol="" Kind="Excluded" />
    <Place Id="cd61be80-4c41-4f90-998c-42b68587fce5" RowId="2768c6d4-fe88-441e-ae8a-4af0060af1bc" ColId="79e43ba6-5488-471e-b46d-ba59c97b4f8c" Symbol="" Kind="Excluded" />
    <Place Id="57b924dc-4c2e-4f16-bab5-9b47f9434d28" RowId="96b8b07e-43cb-4812-9b3f-ce1b95e38cb2" ColId="96af2fb1-3816-410c-b99d-5d9270c13b58" Symbol="" Kind="Excluded" />
    <Place Id="537ed01e-2743-4183-aa60-0d722d42edfe" RowId="96b8b07e-43cb-4812-9b3f-ce1b95e38cb2" ColId="a518716a-fabc-433c-9945-21056b7d1b96" Symbol="" Kind="Excluded" />
    <Place Id="a57db94e-8bb7-4818-af19-9a7acbcf5e37" RowId="96b8b07e-43cb-4812-9b3f-ce1b95e38cb2" ColId="bc7fc15e-0c15-4aa1-b323-a3c6d236c904" Symbol="15" Kind="Excluded" />
    <Place Id="85b49eb4-2674-4b39-98c3-fc99c74293a0" RowId="96b8b07e-43cb-4812-9b3f-ce1b95e38cb2" ColId="faa1bb37-22bc-4b35-8d83-34bef01ce04a" Symbol="14" Kind="Included" />
    <Place Id="1fbb02b0-3cc9-48ea-8f29-63c558424bb9" RowId="96b8b07e-43cb-4812-9b3f-ce1b95e38cb2" ColId="918c650b-9402-4aff-a03b-3770c60e626e" Symbol="13" Kind="Included" />
   ---
  </Places>
  <CoachGroups />

  <CustomGroups>
    <Group Id="4819c2e6-c8fc-455a-98a1-b9d0021703e2" GroupSeatsId="55feabb6-bd57-436c-b4f9-5f5f7ef9b485">
      <Places>
        <Place Id="01c930c9-0d5a-48f4-b5d0-1416c8a8c99f" />
        <Place Id="3609a78d-2d8c-4c96-8b06-2648226cbcab" />
        <Place Id="a10ec0ec-9b5a-4279-a40f-2103104ff979" />
        <Place Id="e7580756-cc38-41a4-b4d1-d356136fe9d5" />
        <Place Id="c189a0db-f53e-4a99-a5cd-7318c4506f2d" />
        <Place Id="67717bd9-e9d2-414f-ae6d-de4c2bd7b53a" />
        <Place Id="39fbca3d-acd6-4248-99d4-d5503151affb" />
        <Place Id="795f2264-5564-4cb4-8c78-c7382b7a2789" />
        <Place Id="c8a8bf32-0626-4a02-ab93-34fd17739787" />
        <Place Id="20e06b4d-333a-42cc-ba16-72eaa92e0eff" />
        <Place Id="9a1d1746-acd1-4cd5-ab86-d24ba1483d8c" />
        <Place Id="b840f33c-2b21-4c89-9eb1-a0bb637e0ab8" />
        <Place Id="66ea913c-1f8f-45d3-b1bb-f6936df9f9db" />
        <Place Id="77540b03-8284-4a2a-ab79-33526ab928fc" />
        <Place Id="a4047c47-59da-43ba-adc3-c0d0a8b0bb14" />
        <Place Id="b9094a20-ce0a-46e6-9db4-f2e9294034cb" />
        <Place Id="c8e6f136-ef51-4853-97e9-ea27458af4cd" />
        <Place Id="6bc7b667-b3a6-4cbb-952f-8cc452476416" />
        <Place Id="ef6edd3f-9da6-4c97-bf17-ea22f6d6f9f6" />
        <Place Id="58b683e4-cacc-4ae8-bff6-bd3816bdc507" />
        <Place Id="0ff27d45-4f6d-47a4-94f7-f7e45ded5d34" />
        <Place Id="9cf8df8e-f79e-4090-b2d6-dc937a474adf" />
        <Place Id="3e5d92f4-db67-4ff3-9d6b-9b8a44fb94c4" />
        <Place Id="9a7659b4-2137-4797-badf-2a40ba09dd3a" />
        <Place Id="e9c7e3fb-67f3-404a-a54f-ebf2d16d8b84" />
        <Place Id="7baca53e-f48b-485f-9d53-ad1a93199194" />
        <Place Id="23c72a9f-e4f9-42bb-a64f-c11af162a8e8" />
      </Places>
    </Group>
    <Group Id="b49c7f1a-1fc2-455e-8d00-41cea3dac82d" GroupSeatsId="55feabb6-bd57-436c-b4f9-5f5f7ef9b485">
      <Places>
        <Place Id="7b116ee5-8f1f-42b8-9eaa-2be6b29ce8d6" />
        <Place Id="c90c7156-9b5f-44eb-8e59-672b4f47c248" />
        <Place Id="ac1200b6-ee15-4c16-9c33-4413c9577b6c" />
        <Place Id="56905ff8-369d-4f6e-8e77-0f5e2f780796" />
        <Place Id="fb03dc89-12a0-49cd-b978-a7e4bc355bdb" />
        <Place Id="35700ff7-6405-4ca8-9e74-a44da2e0d1c0" />
        <Place Id="be980a4e-49ac-4b29-8e25-92937545e088" />
        <Place Id="612734a4-ead9-4fd2-9d14-d0a557464bec" />
        <Place Id="5d318aab-2775-4dd3-81b4-2f78f5d3bcbd" />
        <Place Id="2b6c033d-9be7-41c3-ad14-60a59ef490b0" />
        <Place Id="85b49eb4-2674-4b39-98c3-fc99c74293a0" />
        <Place Id="1fbb02b0-3cc9-48ea-8f29-63c558424bb9" />
        <Place Id="fc41d588-e495-4c4d-91cd-88949f367264" />
        <Place Id="4d401101-207b-4a37-a9fe-957d147712b4" />
        <Place Id="f06b4ceb-7872-4f1c-87f9-5a1bfb428958" />
        <Place Id="a71189db-2198-4c34-b57f-8de5a5938cbf" />
        <Place Id="d675a530-5e9e-4cf4-990a-566386e5fb8a" />
        <Place Id="496b00bf-2e21-4f34-a11a-06235769e84c" />
        <Place Id="15dafb9c-f90a-476f-a6ad-cde5db74407c" />
        <Place Id="a21c3a36-5c6d-42e6-99e6-b1992ec7a37e" />
        <Place Id="5bb4e85f-99f8-4ab2-82e8-d6ae10a316bd" />
        <Place Id="24dc5ffa-c785-4b73-8bc0-1bd43ae591d0" />
        <Place Id="4c323c73-7e2f-401b-a3da-3451a92487fc" />
        <Place Id="8cc1370e-6824-4a34-9d3a-040a155ae229" />
        <Place Id="b2c088c1-e132-432d-b920-907c6c813bc4" />
        <Place Id="93e046f3-03de-4d7a-9654-9ea2d3ba19d5" />
        <Place Id="01ce83f1-3380-42df-9ee0-c300ab432b2b" />
        <Place Id="ca8e2273-8c07-4b99-8c9b-2ccbb709e839" />
        <Place Id="372c67b7-59aa-42a4-9638-ff4e5282d0eb" />
        <Place Id="27f9e128-86df-4280-87e8-9355c1061ce4" />
        <Place Id="27e4b385-965d-4c17-8e38-8cbbdd136a3f" />
        <Place Id="b2610871-3fb1-48e5-917e-d7148358861f" />
        <Place Id="b6a61399-2fca-4a36-95ce-04faaf1de30c" />
        <Place Id="e1f7d937-65dd-4e63-9cfa-a032d8c0e19f" />
        <Place Id="8e5cc633-f5c5-4067-9f8d-76bd0cd28385" />
        <Place Id="ce74b491-f868-403b-b5e5-4366426e8a8c" />
        <Place Id="6d9c175d-97f9-4132-9209-c55f2152aeb0" />
        <Place Id="b5c7b2fc-c4ad-4e9d-bc6e-8cb07afe9273" />
        <Place Id="c20cd9ca-70bd-4851-8675-f02a48ea1271" />
        <Place Id="df9f060e-fc32-4bd7-b3f7-52898779008c" />
        <Place Id="655bb2b5-a7a0-4794-bfca-9feb355ba97b" />
        <Place Id="ef8eb9b0-9129-41a8-adb2-a28208a729ee" />
        <Place Id="4faa4dbb-5066-42a7-a5fa-ea2295d12ca4" />
        <Place Id="36adea82-928a-4c0d-9fb0-d147e09ca181" />
        <Place Id="8ddc5442-16fe-4af5-9548-efdc4f6d7dd8" />
        <Place Id="cd7db0bf-cc5a-498f-bdf1-75adcaa0e0ce" />
        <Place Id="465e5048-e063-43ab-8375-dc0a2a930054" />
        <Place Id="97905665-0f1a-42c2-bf0a-76c4156ea678" />
        <Place Id="4364e8b7-1113-4ba8-b103-91ce542c03e2" />
        <Place Id="545f2336-dad9-4378-9948-d138394a657c" />
        <Place Id="4307cc49-4cea-4089-8f5f-7992eb9d10f7" />
        <Place Id="29dc4b9a-3239-451e-baf8-7ded37fe0e03" />
        <Place Id="accf0603-0070-4f4e-8e16-31029ba270ff" />
        <Place Id="d3526c22-0816-457b-bd0a-a830850f3b99" />
        <Place Id="b3540ee8-8b16-42f9-bf99-8a5c1c549cfd" />
        <Place Id="b3fc6e24-ac14-4687-a298-83de9cb3752d" />
        <Place Id="cf27f59c-e85f-44ae-83c6-91b189b94446" />
        <Place Id="fb917c61-4659-47ae-89e6-e40f270f7ddc" />
        <Place Id="f4646afa-b941-4971-a4c3-39538b5fe53a" />
        <Place Id="0331765a-05aa-435e-ae57-46a7d910c79f" />
        <Place Id="a9f3957e-c9e3-4a9e-9c96-64255d449c4a" />
        <Place Id="ce19ce74-e5a2-4a91-96aa-eb1ab37d094b" />
        <Place Id="d1c31454-291a-418e-8d9b-f95b1e60658b" />
        <Place Id="3f3f222e-2488-46d8-95fe-2b735303a6dc" />
        <Place Id="38e9dc06-52cc-415b-b00f-de344ab28f3d" />
        <Place Id="157e49e4-c2e5-4dcb-bc97-5b311481007e" />
        <Place Id="8979cc1d-93bc-4529-a1d5-41709b54fc89" />
        <Place Id="c7fad1db-261b-46e0-99b3-bcd95b9e7860" />
        <Place Id="95eadfb4-2738-4ce1-b0c7-df76a9dfbf34" />
        <Place Id="426e875c-68fe-41a2-975b-5792ca8b59b6" />
      </Places>
    </Group>
  </CustomGroups>
  <Wheelchairs>
    <Wheelchair Id="03df3286-5ffb-4239-b4af-3ec2ff643df8" PlaceId="a10ec0ec-9b5a-4279-a40f-2103104ff979" />
  </Wheelchairs>
  <LoungeGroups />
  <SalesChannelGroups>
    <Group Id="e00d7780-285b-46d1-ba82-bd1393077b66" BlockedSalesChannelID="0b884544-5660-4c31-9c59-d57e41733b8e">
      <Places>
        <Place Id="e7580756-cc38-41a4-b4d1-d356136fe9d5" />
        <Place Id="c189a0db-f53e-4a99-a5cd-7318c4506f2d" />
        <Place Id="c6828de4-1696-44ac-b2e4-bdce7cb25fd7" />
      </Places>
    </Group>
    <Group Id="78c91c03-b754-403c-8f43-b78deb92afd4" BlockedSalesChannelID="5cb99449-ca4d-4a83-b3bb-2e57c8c2f98d">
      <Places>
        <Place Id="e7580756-cc38-41a4-b4d1-d356136fe9d5" />
        <Place Id="c189a0db-f53e-4a99-a5cd-7318c4506f2d" />
        <Place Id="c6828de4-1696-44ac-b2e4-bdce7cb25fd7" />
      </Places>
    </Group>
    <Group Id="702b51c3-50c0-4077-9a29-da8091ea0c67" BlockedSalesChannelID="1a1fe703-587a-4885-8fd3-496b7321d4b9">
      <Places>
        <Place Id="e7580756-cc38-41a4-b4d1-d356136fe9d5" />
        <Place Id="c189a0db-f53e-4a99-a5cd-7318c4506f2d" />
        <Place Id="c6828de4-1696-44ac-b2e4-bdce7cb25fd7" />
      </Places>
    </Group>
    <Group Id="6275ae54-e3c7-412d-801d-c60a948fb2a0" BlockedSalesChannelID="fc483f27-ba50-4441-a609-65cadb6d6564">
      <Places>
        <Place Id="e7580756-cc38-41a4-b4d1-d356136fe9d5" />
        <Place Id="c189a0db-f53e-4a99-a5cd-7318c4506f2d" />
        <Place Id="c6828de4-1696-44ac-b2e4-bdce7cb25fd7" />
      </Places>
    </Group>
    <Group Id="31ad6d3b-a84e-49f9-af10-3c45d0f7a7b8" BlockedSalesChannelID="0b884544-5660-4c31-9c59-d57e41733b8e">
      <Places>
        <Place Id="2b6c033d-9be7-41c3-ad14-60a59ef490b0" />
        <Place Id="5d318aab-2775-4dd3-81b4-2f78f5d3bcbd" />
        <Place Id="612734a4-ead9-4fd2-9d14-d0a557464bec" />
        <Place Id="be980a4e-49ac-4b29-8e25-92937545e088" />
        <Place Id="35700ff7-6405-4ca8-9e74-a44da2e0d1c0" />
        <Place Id="fb03dc89-12a0-49cd-b978-a7e4bc355bdb" />
        <Place Id="56905ff8-369d-4f6e-8e77-0f5e2f780796" />
        <Place Id="ac1200b6-ee15-4c16-9c33-4413c9577b6c" />
        <Place Id="c90c7156-9b5f-44eb-8e59-672b4f47c248" />
        <Place Id="7b116ee5-8f1f-42b8-9eaa-2be6b29ce8d6" />
        <Place Id="a21c3a36-5c6d-42e6-99e6-b1992ec7a37e" />
        <Place Id="15dafb9c-f90a-476f-a6ad-cde5db74407c" />
        <Place Id="496b00bf-2e21-4f34-a11a-06235769e84c" />
        <Place Id="d675a530-5e9e-4cf4-990a-566386e5fb8a" />
        <Place Id="a71189db-2198-4c34-b57f-8de5a5938cbf" />
        <Place Id="f06b4ceb-7872-4f1c-87f9-5a1bfb428958" />
        <Place Id="4d401101-207b-4a37-a9fe-957d147712b4" />
        <Place Id="fc41d588-e495-4c4d-91cd-88949f367264" />
        <Place Id="1fbb02b0-3cc9-48ea-8f29-63c558424bb9" />
        <Place Id="85b49eb4-2674-4b39-98c3-fc99c74293a0" />
        <Place Id="5bb4e85f-99f8-4ab2-82e8-d6ae10a316bd" />
        <Place Id="24dc5ffa-c785-4b73-8bc0-1bd43ae591d0" />
        <Place Id="27f9e128-86df-4280-87e8-9355c1061ce4" />
        <Place Id="372c67b7-59aa-42a4-9638-ff4e5282d0eb" />
        <Place Id="ca8e2273-8c07-4b99-8c9b-2ccbb709e839" />
        <Place Id="01ce83f1-3380-42df-9ee0-c300ab432b2b" />
      </Places>
    </Group>
    <Group Id="7f420e48-32e2-43ec-9ff1-879fc8142665" BlockedSalesChannelID="5cb99449-ca4d-4a83-b3bb-2e57c8c2f98d">
      <Places>
        <Place Id="7b116ee5-8f1f-42b8-9eaa-2be6b29ce8d6" />
        <Place Id="c90c7156-9b5f-44eb-8e59-672b4f47c248" />
        <Place Id="0f5995ce-47ac-453d-b37c-a04d1dcbd211" />
        <Place Id="ac1200b6-ee15-4c16-9c33-4413c9577b6c" />
        <Place Id="56905ff8-369d-4f6e-8e77-0f5e2f780796" />
        <Place Id="e6fb8ad4-b1be-4017-a753-4cac31adf423" />
        <Place Id="fb03dc89-12a0-49cd-b978-a7e4bc355bdb" />
        <Place Id="35700ff7-6405-4ca8-9e74-a44da2e0d1c0" />
        <Place Id="f3be70c9-93a7-4824-b4b0-3d8d6bc317a5" />
        <Place Id="be980a4e-49ac-4b29-8e25-92937545e088" />
        <Place Id="612734a4-ead9-4fd2-9d14-d0a557464bec" />
        <Place Id="f753c89a-6e9a-4dbb-bf37-2110ab941293" />
        <Place Id="5d318aab-2775-4dd3-81b4-2f78f5d3bcbd" />
        <Place Id="2b6c033d-9be7-41c3-ad14-60a59ef490b0" />
        <Place Id="3aea20d0-ec44-48b4-8456-0d923499c299" />
        <Place Id="a57db94e-8bb7-4818-af19-9a7acbcf5e37" />
        <Place Id="85b49eb4-2674-4b39-98c3-fc99c74293a0" />
        <Place Id="1fbb02b0-3cc9-48ea-8f29-63c558424bb9" />
        <Place Id="9ed0fd93-9482-40a1-840a-9f3f880bbb0b" />
        <Place Id="fc41d588-e495-4c4d-91cd-88949f367264" />
        <Place Id="4d401101-207b-4a37-a9fe-957d147712b4" />
        <Place Id="fd961ab9-886e-47d6-9be6-8acb47a2765b" />
        <Place Id="f06b4ceb-7872-4f1c-87f9-5a1bfb428958" />
        <Place Id="a71189db-2198-4c34-b57f-8de5a5938cbf" />
        <Place Id="12d9bfe8-6929-49bf-a78d-d17cf7685c9b" />
        <Place Id="d675a530-5e9e-4cf4-990a-566386e5fb8a" />
        <Place Id="496b00bf-2e21-4f34-a11a-06235769e84c" />
        <Place Id="0bf88c52-6c56-481c-943e-1c174de79d25" />
        <Place Id="15dafb9c-f90a-476f-a6ad-cde5db74407c" />
        <Place Id="a21c3a36-5c6d-42e6-99e6-b1992ec7a37e" />
        <Place Id="5bb4e85f-99f8-4ab2-82e8-d6ae10a316bd" />
        <Place Id="24dc5ffa-c785-4b73-8bc0-1bd43ae591d0" />
        <Place Id="372c67b7-59aa-42a4-9638-ff4e5282d0eb" />
        <Place Id="27f9e128-86df-4280-87e8-9355c1061ce4" />
        <Place Id="3f409342-70a1-4d2d-b933-bf8726c9be21" />
      </Places>
    </Group>
    <Group Id="cec9e7d5-24af-40dc-89e4-2a3d220499f6" BlockedSalesChannelID="1a1fe703-587a-4885-8fd3-496b7321d4b9">
      <Places>
        <Place Id="7b116ee5-8f1f-42b8-9eaa-2be6b29ce8d6" />
        <Place Id="c90c7156-9b5f-44eb-8e59-672b4f47c248" />
        <Place Id="0f5995ce-47ac-453d-b37c-a04d1dcbd211" />
        <Place Id="ac1200b6-ee15-4c16-9c33-4413c9577b6c" />
        <Place Id="56905ff8-369d-4f6e-8e77-0f5e2f780796" />
        <Place Id="e6fb8ad4-b1be-4017-a753-4cac31adf423" />
        <Place Id="fb03dc89-12a0-49cd-b978-a7e4bc355bdb" />
        <Place Id="35700ff7-6405-4ca8-9e74-a44da2e0d1c0" />
        <Place Id="f3be70c9-93a7-4824-b4b0-3d8d6bc317a5" />
        <Place Id="be980a4e-49ac-4b29-8e25-92937545e088" />
        <Place Id="612734a4-ead9-4fd2-9d14-d0a557464bec" />
        <Place Id="f753c89a-6e9a-4dbb-bf37-2110ab941293" />
        <Place Id="5d318aab-2775-4dd3-81b4-2f78f5d3bcbd" />
        <Place Id="2b6c033d-9be7-41c3-ad14-60a59ef490b0" />
        <Place Id="3aea20d0-ec44-48b4-8456-0d923499c299" />
        <Place Id="a57db94e-8bb7-4818-af19-9a7acbcf5e37" />
        <Place Id="85b49eb4-2674-4b39-98c3-fc99c74293a0" />
        <Place Id="1fbb02b0-3cc9-48ea-8f29-63c558424bb9" />
        <Place Id="9ed0fd93-9482-40a1-840a-9f3f880bbb0b" />
        <Place Id="fc41d588-e495-4c4d-91cd-88949f367264" />
        <Place Id="4d401101-207b-4a37-a9fe-957d147712b4" />
        <Place Id="fd961ab9-886e-47d6-9be6-8acb47a2765b" />
        <Place Id="f06b4ceb-7872-4f1c-87f9-5a1bfb428958" />
        <Place Id="a71189db-2198-4c34-b57f-8de5a5938cbf" />
        <Place Id="12d9bfe8-6929-49bf-a78d-d17cf7685c9b" />
        <Place Id="d675a530-5e9e-4cf4-990a-566386e5fb8a" />
        <Place Id="496b00bf-2e21-4f34-a11a-06235769e84c" />
        <Place Id="0bf88c52-6c56-481c-943e-1c174de79d25" />
        <Place Id="15dafb9c-f90a-476f-a6ad-cde5db74407c" />
        <Place Id="a21c3a36-5c6d-42e6-99e6-b1992ec7a37e" />
        <Place Id="5bb4e85f-99f8-4ab2-82e8-d6ae10a316bd" />
        <Place Id="24dc5ffa-c785-4b73-8bc0-1bd43ae591d0" />
        <Place Id="372c67b7-59aa-42a4-9638-ff4e5282d0eb" />
        <Place Id="27f9e128-86df-4280-87e8-9355c1061ce4" />
        <Place Id="3f409342-70a1-4d2d-b933-bf8726c9be21" />
      </Places>
    </Group>
    <Group Id="f3329004-7163-46e8-9888-3ecd1551e4c6" BlockedSalesChannelID="fc483f27-ba50-4441-a609-65cadb6d6564">
      <Places>
        <Place Id="7b116ee5-8f1f-42b8-9eaa-2be6b29ce8d6" />
        <Place Id="c90c7156-9b5f-44eb-8e59-672b4f47c248" />
        <Place Id="0f5995ce-47ac-453d-b37c-a04d1dcbd211" />
        <Place Id="ac1200b6-ee15-4c16-9c33-4413c9577b6c" />
        <Place Id="56905ff8-369d-4f6e-8e77-0f5e2f780796" />
        <Place Id="e6fb8ad4-b1be-4017-a753-4cac31adf423" />
        <Place Id="fb03dc89-12a0-49cd-b978-a7e4bc355bdb" />
        <Place Id="35700ff7-6405-4ca8-9e74-a44da2e0d1c0" />
        <Place Id="f3be70c9-93a7-4824-b4b0-3d8d6bc317a5" />
        <Place Id="be980a4e-49ac-4b29-8e25-92937545e088" />
        <Place Id="612734a4-ead9-4fd2-9d14-d0a557464bec" />
        <Place Id="f753c89a-6e9a-4dbb-bf37-2110ab941293" />
        <Place Id="5d318aab-2775-4dd3-81b4-2f78f5d3bcbd" />
        <Place Id="2b6c033d-9be7-41c3-ad14-60a59ef490b0" />
        <Place Id="3aea20d0-ec44-48b4-8456-0d923499c299" />
        <Place Id="a57db94e-8bb7-4818-af19-9a7acbcf5e37" />
        <Place Id="85b49eb4-2674-4b39-98c3-fc99c74293a0" />
        <Place Id="1fbb02b0-3cc9-48ea-8f29-63c558424bb9" />
        <Place Id="9ed0fd93-9482-40a1-840a-9f3f880bbb0b" />
        <Place Id="fc41d588-e495-4c4d-91cd-88949f367264" />
        <Place Id="4d401101-207b-4a37-a9fe-957d147712b4" />
        <Place Id="fd961ab9-886e-47d6-9be6-8acb47a2765b" />
        <Place Id="f06b4ceb-7872-4f1c-87f9-5a1bfb428958" />
        <Place Id="a71189db-2198-4c34-b57f-8de5a5938cbf" />
        <Place Id="12d9bfe8-6929-49bf-a78d-d17cf7685c9b" />
        <Place Id="d675a530-5e9e-4cf4-990a-566386e5fb8a" />
        <Place Id="496b00bf-2e21-4f34-a11a-06235769e84c" />
        <Place Id="0bf88c52-6c56-481c-943e-1c174de79d25" />
        <Place Id="15dafb9c-f90a-476f-a6ad-cde5db74407c" />
        <Place Id="a21c3a36-5c6d-42e6-99e6-b1992ec7a37e" />
        <Place Id="5bb4e85f-99f8-4ab2-82e8-d6ae10a316bd" />
        <Place Id="24dc5ffa-c785-4b73-8bc0-1bd43ae591d0" />
        <Place Id="372c67b7-59aa-42a4-9638-ff4e5282d0eb" />
        <Place Id="27f9e128-86df-4280-87e8-9355c1061ce4" />
        <Place Id="3f409342-70a1-4d2d-b933-bf8726c9be21" />
      </Places>
    </Group>
  </SalesChannelGroups>
</IGPosEvtHallStruct>

There are approximately 500 rows in the table. The XML column data is of similar format. The only valuable data exists are in the CustomGroup Section (it can be 1 or 2 sections. Nevertheless all of those are needed). Can someone help me to convert the output of this table and XML into a new table with the below columns:

ID (from above table)
DS_RowGuid
PCScreenStructureVariantID
GroupID
GroupSeatsID
PlaceId

Much appreciated.

CodePudding user response:

You can use the following code:

SELECT
  t.ID,
  t.DS_RowGuid,
  t.PCScreenStructureVariantID,
  GroupID      = x1.Groups.value('@Id'          ,'uniqueidentifier'),
  GroupSeatsID = x1.Groups.value('@GroupSeatsId','uniqueidentifier'),
  PlaceId      = x2.Places.value('@Id'          ,'uniqueidentifier')
FROM YourTable t
CROSS APPLY t.XML.nodes('IGPosEvtHallStruct/CustomGroups/Group') x1(Groups)
CROSS APPLY x1.Groups.nodes('Places/Place') x2(Places);

db<>fiddle

  • Note how the first .nodes breaks out the Group nodes, and is then fed into the second one to break out the Place nodes. This is only necessary because we are selecting from two different levels of the XML
  • When using .value the XQuery must be known to be exactly one node. This is only true with attributes (referred by @), but if you wanted a node's inner text value, you would need '.value('(someNode/text())[1]', etc
  • Related