1
これは私のSQLクエリでネストされたXMLのSQLクエリ
SELECT
(SELECT TOP 2
Docnum AS [PONUMBER],
(SELECT FirstName + lastName AS [CreatedBy]
FROM OHEM
WHERE empID = T0.OwnerCode) AS OwnerCode,
T0.CardCode AS [VENDOR_NO],
CardName AS [VENDOR_NAME],
T0.U_TelFax AS [TELENO],
T0.DocDate AS [PODATE],
'SPX' AS [COMPCODE],
Comments AS [HEAD_TXT],
U_ETA AS [EXPDATE],
U_No_of_packages AS [ESTIMATEDPACKAGES],
REPLACE(REPLACE(T0.Address2, CHAR(10), ''), CHAR(13), '') AS [STREET]
FROM
OPOR T0
ORDER BY
CreateDate DESC
FOR XML PATH('ZPOHEAD_DATA'), ROOT('POHEAD'), TYPE) POXML
これは、私の出力です:
<POHEAD>
<ZPOHEAD_DATA>
<PONUMBER>25611</PONUMBER>
<OwnerCode>CandyLai</OwnerCode>
<VENDOR_NO>V-0410-EUR</VENDOR_NO>
<VENDOR_NAME>Robopac S.p.A.</VENDOR_NAME>
<PODATE>2017-10-04T00:00:00</PODATE>
<COMPCODE>SPX</COMPCODE>
<HEAD_TXT>Based On Purchase Request 8315. 8321.</HEAD_TXT>
<STREET>23A Tech Park CrescentSingapore 637848</STREET>
</ZPOHEAD_DATA>
<ZPOHEAD_DATA>
<PONUMBER>25612</PONUMBER>
<OwnerCode>CandyLai</OwnerCode>
<VENDOR_NO>V-0157-SGD</VENDOR_NO>
<VENDOR_NAME>Eltete Malaysia Sdn Bhd</VENDOR_NAME>
<PODATE>2017-10-04T00:00:00</PODATE>
<COMPCODE>SPX</COMPCODE>
<HEAD_TXT>*yb mrp</HEAD_TXT>
<STREET>15 Joo Koon Road Singapore 628976</STREET>
</ZPOHEAD_DATA>
</POHEAD>
しかし、私はこのようになり出力を必要とする - ベースのクエリを変更するために私を助けてください下の出力に
<POXML>
<POHEAD>
<ZPOHEAD_DATA>
<PONUMBER>25611</PONUMBER>
<OwnerCode>CandyLai</OwnerCode>
<VENDOR_NO>V-0410-EUR</VENDOR_NO>
<VENDOR_NAME>Robopac S.p.A.</VENDOR_NAME>
<PODATE>2017-10-04T00:00:00</PODATE>
<COMPCODE>SPX</COMPCODE>
<HEAD_TXT>Based On Purchase Request 8315. 8321.</HEAD_TXT>
<STREET>23A Tech Park CrescentSingapore 637848</STREET>
</ZPOHEAD_DATA>
</POHEAD>
<POHEAD>
<ZPOHEAD_DATA>
<PONUMBER>25612</PONUMBER>
<OwnerCode>CandyLai</OwnerCode>
<VENDOR_NO>V-0157-SGD</VENDOR_NO>
<VENDOR_NAME>Eltete Malaysia Sdn Bhd</VENDOR_NAME>
<PODATE>2017-10-04T00:00:00</PODATE>
<COMPCODE>SPX</COMPCODE>
<HEAD_TXT>*yb mrp</HEAD_TXT>
<STREET>15 Joo Koon Road Singapore 628976</STREET>
</ZPOHEAD_DATA>
</POHEAD>
</POXML>
質問を編集サンプルのデータを追加してください。 –