WITH XMLNAMESPACES

**APPLIES TO:** ![yes](media/yes.png)SQL Server (starting with 2008) ![no](media/no.png)Azure SQL Database ![no](media/no.png)Azure SQL Data Warehouse ![no](media/no.png)Parallel Data Warehouse

Declares one or more XML namespaces.

Topic link icon Transact-SQL Syntax Conventions

Syntax

  
WITH XMLNAMESPACES ( <XML namespace declaration item>  
[ { , <XML namespace declaration item> }...] )   
  
<XML namespace declaration item> ::=  
<xml_namespace_uri> AS <xml_namespace_prefix>  
| <XML default namespace declaration item>  
<xml_namespace_uri> ::= <character string literal>  
  
<xml_namespace_prefix> ::= <identifier>  
  
<XML default namespace declaration item> ::=  
DEFAULT <xml_namespace_uri>  
  

Arguments

xml_namespace_uri
A Uniform Resource Identifier (URI) that identifies the XML namespace that is being declared. xml_namespace_uri is an SQL string.

xml_namespace_prefix
Specifies a prefix to be mapped and associated with the namespace URI value specified in xml_namespace_uri. xml_namespace_prefix must be a SQL Server identifier.

Remarks

When you use the WITH XMLNAMESPACES clause in a statement that also includes a common table expression, the WITH XMLNAMESPACES clause must precede the common table expression in the statement.

The following are general syntax rules that apply when you use the WITH XMLNAMESPACES clause:

Examples

For examples, see Add Namespaces to Queries with WITH XMLNAMESPACES.

See Also

XQuery Language Reference (SQL Server)