Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 10.0.1 » SQL Anywhere Server - SQL Usage » Using XML in the Database » Using SQL/XML to obtain query results as XML

Using the XMLAGG function Next Page

Using the XMLCONCAT function


The XMLCONCAT function creates a forest of XML elements by concatenating all the XML values passed in. For example, the following query concatenates the <given_name> and <surname> elements for each employee in the Employees table:

SELECT XMLCONCAT( XMLELEMENT( NAME given_name, GivenName ),
                  XMLELEMENT( NAME surname, Surname )
                 ) AS "Employee_Name"
FROM Employees;

This query returns the following result:

Employee_Name
<given_name>Fran</given_name>
<surname>Whitney</surname>
<given_name>Matthew</given_name>
<surname>Cobb</surname>
<given_name>Philip</given_name>
<surname>Chin</surname>
<given_name>Julie</given_name>
<surname>Jordan</surname>
...

For more information, see XMLCONCAT function [String].