私は次のXMLを持っています
<Queue>
    <UserName>UserName</UserName>
    <Type>1</Type>
    <Portal name="Portal1">
        <IndexesForSelect>
            <Index>Index1</Index>
            <Index>Index2</Index>
        </IndexesForSelect>
    </Portal>
    <Portal name="Portal2">
        <IndexesForSelect>
            <Index>Index3</Index>
            <Index>Index4</Index>
        </IndexesForSelect>
    </Portal>
</Queue>
そして、私はそれを以下の形式のテーブルに取得する必要があります
Portal      Index
---------------------------
Portal1     Index1
Portal1     Index2
Portal2     Index3
Portal2     Index4
誰かが私を助けてくれれば本当に感謝しています。
次のコードを試しましたが、最初Indexにしか返されませんPortal
declare @T table
(
  XMLCol xml
)
insert into @T values
('<Queue>
      <UserName>UserName</UserName>
      <Type>1</Type>
      <Portal name="Portal1">
        <IndexesForSelect>
          <Index>Index1</Index>
          <Index>Index2</Index>
        </IndexesForSelect>
      </Portal>
      <Portal name="Portal2">
        <IndexesForSelect>
          <Index>Index3</Index>
          <Index>Index4</Index>
        </IndexesForSelect>
      </Portal>
    </Queue>')
SELECT  items.value('../@name','varchar(max)') AS [Portal],
        items.value('(Index)[1]','varchar(max)') AS [Index]
FROM @T AS T CROSS APPLY T.XMLCol.nodes('Queue/Portal/IndexesForSelect') c (items)