Udostępnij za pośrednictwem


Komentarze w trybie XQuery

Dotyczy:programu SQL Server

Możesz dodawać komentarze do zapytania XQuery. Ciągi komentarzy są dodawane przy użyciu ograniczników "(:" i ":)". Na przykład:

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

Poniżej znajduje się inny przykład, w którym zapytanie jest określone względem kolumny Instrukcja xml typu:

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