Share via


XQuery 中的註解

您可以將註解加入到 XQuery。註解字串是利用 "(:" 和 ":)" 分隔符號來加入。例如:

declare @x xml
set @x=''
SELECT @x.query('
(: simple query to construct an element :)
<ProductModel ProductModelID="10" />
')

以下是針對 xml 類型的 Instruction 資料行指定查詢的另一個範例:

SELECT Instructions.query('
(: declare prefix and namespace binding in the prolog. :)
     declare namespace AWMI="https://schemas.microsoft.com/sqlserver/2004/07/adventure-works/ProductModelManuInstructions";
  (: Following expression retrieves the <Location> element children of the <root> element. :)
  /AWMI:root/AWMI:Location
') as Result
FROM Production.ProductModel
where ProductModelID=7