Skip to main content

XMLCONCAT (SQL)

A function that concatenates XML elements.

Synopsis

XMLCONCAT(XmlElement1,XmlElement2[,...])

Description

The XMLCONCAT function returns the values from several XMLELEMENT functions as a single string. XMLCONCAT can be used in a SELECT query or subquery that references either a table or a view. XMLCONCAT can appear in a SELECT list alongside ordinary field values.

Arguments

XmlElement

An XMLELEMENT function. Specify two or more XmlElement to concatenate.

Examples

The following query concatenates the values from two XMLELEMENT functions:

SELECT Name,XMLCONCAT(XMLELEMENT("Para",Name),
                      XMLELEMENT("Para",Home_City)) AS ExportString
     FROM Sample.Person

A sample row of the data returned would appear as follows:

ExportString
<Para>Emerson,Molly N.</Para><Para>Boston</Para>

The following query nests an XMLCONCAT within an XMLELEMENT function:

SELECT XMLELEMENT("Item",Name,
          XMLCONCAT(
              XMLELEMENT("Para",Home_City,' ',Home_State),
              XMLELEMENT("Para",'is residence')))
       AS ExportString
FROM Sample.Person

A sample row of the data returned would appear as follows:

ExportString
<Item>Emerson,Molly N.<Para>Boston MA</Para><Para>is residence</Para></Item> 

See Also

SELECT statement

XMLAGG function

XMLELEMENT function

FeedbackOpens in a new tab