Share via


Commenti in query XQuery

È possibile aggiungere commenti in una query XQuery. Per aggiungere stringhe di commento, utilizzare i delimitatori "(:" e ":)". Ad esempio:

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

Di seguito è riportato un altro esempio in cui viene eseguita una query su una colonna Instructions di tipo 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