Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

xml_schema_namespace (Transact-SQL)

Applies To: SQL Server 2014, SQL Server 2016 Preview

Topic Status: Some information in this topic is preview and subject to change in future releases. Preview information describes new features or changes to existing features in Microsoft SQL Server 2016 Community Technology Preview 2 (CTP2).

Reconstructs all the schemas or a specific schema in the specified XML schema collection. This function returns an xml data type instance.

Applies to: SQL Server (SQL Server 2008 through current version).

Topic link icon Transact-SQL Syntax Conventions

xml_schema_namespace( Relational_schema , XML_schema_collection_name , [ Namespace ] )

Relational_schema

Is the relational schema name. Relational_schema is sysname.

XML_schema_collection_name

Is the name of the XML schema collection to reconstruct. XML_schema_collection_name is sysname.

Namespace

Is the namespace URI of the XML schema that you want reconstructed. It is limited to 1,000 characters. If Namespace URI is not provided, the whole XML schema collection is reconstructed. Namespace is nvarchar(4000).

When you import XML schema components in the database by using CREATE XML SCHEMA COLLECTION or ALTER XML SCHEMA COLLECTION, aspects of the schema used for validation are preserved. Therefore, the reconstructed schema may not be lexically the same as the original schema document. Specifically, comments, white spaces, and annotations are lost; and implicit type information is made explicit. For example, <xs:element name="e1" /> becomes <xs:element name="e1" type="xs:anyType"/>. Also, namespace prefixes are not preserved.

If you specify a namespace parameter, the resulting schema document will contain definitions for all schema components in that namespace, even if they were added in different schema documents or DDL steps, or both.

You cannot use this function to construct XML schema documents from the sys.sys XML schema collection.

The following example retrieves the XML schema collection ProductDescriptionSchemaCollection from the production relational schema in the AdventureWorks2012 database.

USE AdventureWorks2012;
GO
SELECT xml_schema_namespace(N'production',N'ProductDescriptionSchemaCollection');
GO

Community Additions

ADD
Show:
© 2015 Microsoft