The new WITH XMLNAMESPACES clause


FOR XML in SQL Server 2000 puts the burden of generating and maintaining XML namespaces completely on the query writer. XML namespace declaration attributes have to be created like every other attribute with the namespace URI being the column value. Unless the generated XML was in attribute-centric form, this meant that the query has to be written using the EXPLICIT mode. In order to simplify the use of XML namespaces in FOR XML, we have added support for the WITH XMLNAMESPACES clause starting in SQL Server 2005’s April CTP. The WITH XMLNAMESPACES clause that has been defined in the SQL:2003 standard is an extension to the WITH clause that is commonly used to define common table expressions and can be placed on top-level SQL statements such as SELECT, INSERT and UPDATE statements and can be used inside a CREATE VIEW statement.


For more details and examples, please continue here

Comments (0)

Skip to main content