分享方式:


XQuery 中的註解

適用於:SQL Server

您可以將批註新增至 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