0
我不是XML查詢的專家......但我只需要一小步就可以達到我的目標。嵌套子標記結果集xml T-SQL
使用下面的查詢。
我在EANs標籤中遇到了子標籤EAN的問題。
SELECT
ExternalId,
[Name],
[Description],
BrandExternalId,
CategoryExternalId,
ProductPageUrl,
ImageUrl,
(SELECT ManufacturerPartNumber
FOR XML PATH('ManufacturerPartNumbers'), TYPE),
(SELECT b.EAN_Single as EAN
FROM #SP b
WHERE (ff.ExternalId = b.codart)
FOR XML PATH('EANs'), TYPE)
FROM
Cestino.acap.Bazaar_Servizio_00 ff with (nolock)
WHERE
[ExternalId] IN (100001023)
FOR XML PATH ('Product'), ROOT('Products');
我得到這樣的結果:
<Products>
<Product>
<ExternalId>100001023</ExternalId>
<Name>Carta Lucida Adesiva Photo Stickers PS-101</Name>
<Description>Carta lucida Photo Stickers.</Description>
<BrandExternalId>CANON</BrandExternalId>
<CategoryExternalId>10132</CategoryExternalId>
<ManufacturerPartNumbers>
<ManufacturerPartNumber>0001C001</ManufacturerPartNumber>
</ManufacturerPartNumbers>
<EANs>
<EAN>0138030471030</EAN>
</EANs>
<EANs>
<EAN>5051749491517</EAN>
</EANs>
</Product>
</Products>
,但我需要的結果是這樣的:
<EANs>
<EAN>0138030471030</EAN>
<EAN>5051749491517</EAN>
</EANs>
有人可以幫助我?
感謝阿倫,意大利
非常感謝!完善! ALEN – ACaps