| title | Namespace Support in PATH Mode | ||
|---|---|---|---|
| description | Learn about namespace support when using PATH mode to generate XML from a SELECT query. | ||
| author | MikeRayMSFT | ||
| ms.author | mikeray | ||
| ms.reviewer | randolphwest | ||
| ms.date | 05/05/2022 | ||
| ms.service | sql | ||
| ms.subservice | xml | ||
| ms.topic | conceptual | ||
| ms.custom |
|
||
| helpviewer_keywords |
|
[!INCLUDE SQL Server Azure SQL Database FabricSQLDB]
Namespace support in the PATH mode is provided by using WITH NAMESPACES. For example, the following query demonstrates the WITH NAMESPACES syntax to declare a namespace ("a:") that can then be used in the subsequent SELECT statement:
WITH XMLNAMESPACES('a' as a)
SELECT 1 as 'a:b'
FOR XML PATH;These samples illustrate the use of PATH mode in generating XML from a SELECT query. Many of these queries are specified against the bicycle manufacturing instructions XML documents that are stored in the Instructions column of the ProductModel table.