私は WITH XMLNAMESPACES を初めて使用し、exist() メソッドを使用して結果を生成するのに苦労しています。私が照会しているxml列は次のとおりです。
<Root>
<ProductDescription ProductID="1" ProductName="Road Bike">
<Features>
<Warranty>1 year parts and labor</Warranty>
<Maintenance>3 year parts and labor extended maintenance is
available
</Maintenance>
</Features>
</ProductDescription>
</Root>
Microsoft. ただし、次のクエリを実行すると、0 の結果が得られます。ただし、WHERE 句からエイリアスを削除すると、結果が生成されます。
WITH XMLNAMESPACES ('uri' as pd)
SELECT
Trans_ID,
Bike_Sales.query
(
'<ProductDescription Product_ID = "{ sql:column("Trans_ID")}"/>'
) AS Result
FROM XML_EXAMPLE
WHERE
Bike_Sales.exist
(
'/pd:Root/ProductDescription[(pd:Features)]'
) = 1
したがって、基本的には、Features 要素が存在する行を返したいだけです。助言がありますか?
ありがとう。