Delen via


Opmerkingen in XQuery

Van toepassing op:SQL Server

Je kunt opmerkingen toevoegen aan XQuery. Voeg commentaarstrings toe door de scheidingstekens en :) te (: gebruiken. Voorbeeld:

DECLARE @x AS XML;
SET @x = '';

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

Het volgende voorbeeld toont een zoekopdracht tegen een Instructions kolom van het xml-type :

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;