适用范围:SQL Server
可以在 XQuery 中添加注释。 通过使用 (: 和 :) 分隔符添加注释字符串。 例如:
DECLARE @x AS XML;
SET @x = '';
SELECT @x.query('
(: simple query to construct an element :)
<ProductModel ProductModelID = "10" />
');
以下示例展示了对 InstructionsXML 类型的列的查询:
SELECT Instructions.query('
(: declare prefix and namespace binding in the prolog. :)
declare namespace AWMI = "http://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;