Teilen über


Kommentare in XQuery

Gilt für:SQL Server

Sie können Kommentare zu XQuery hinzufügen. Fügen Sie Kommentar-Strings hinzu, indem Sie die Trennzeichen und :) verwenden(:. Zum Beispiel:

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

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

Das folgende Beispiel zeigt eine Abfrage gegen eine Instructions Spalte des XML-Typs :

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;