XQuery 中的注释

可以向 XQuery 添加注释。注释字符串是通过使用“(:”和“:)”分隔符来添加。例如:

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

下面的示例中指定了一个针对 xml 类型的指令列的查询:

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