--- title: "Request schemas as results with XMLDATA & XMLSCHEMA | Microsoft Docs" ms.date: "03/01/2017" ms.prod: sql ms.prod_service: "database-engine" ms.reviewer: "" ms.technology: xml ms.topic: conceptual helpviewer_keywords: - "RAW mode, requesting schema example" - "RAW mode, with XMLDATA and XMLSCHEMA" ms.assetid: 3504ca38-be66-42b2-8dab-f499c9584840 author: MightyPen ms.author: genemi ms.custom: "seo-lt-2019" --- # Request schemas as results with XMLDATA & XMLSCHEMA [!INCLUDE[appliesto-ss-asdb-xxxx-xxx-md](../../includes/appliesto-ss-asdb-xxxx-xxx-md.md)] The following query returns the XML-DATA schema that describes the document structure. ## Example ``` USE AdventureWorks2012; GO SELECT ProductModelID, Name FROM Production.ProductModel WHERE ProductModelID=122 or ProductModelID=119 FOR XML RAW, XMLDATA GO ``` This is the result: ``` ``` > [!NOTE] > The <`Schema`> is declared as a namespace. To avoid namespace collisions when multiple XML-Data schemas are requested in different FOR XML queries, the namespace identifier, `Schema1` in this example, changes with every query execution. The namespace identifier is made up of **Schema**_**n**_ where _**n**_ is an integer. By specifying the `XMLSCHEMA` option, you can request the XSD schema for the result. ``` USE AdventureWorks2012; GO SELECT ProductModelID, Name FROM Production.ProductModel WHERE ProductModelID=122 or ProductModelID=119 FOR XML RAW, XMLSCHEMA GO ``` This is the result: ``` ``` You can specify the target namespace URI as an optional argument to XMLSCHEMA in FOR XML. This returns the specified target namespace in the schema. This target namespace remains the same every time you execute the query. For example, the following modified version of the previous query includes the namespace URI, `'urn:example.com'`, as an argument. ``` USE AdventureWorks2012; GO SELECT ProductModelID, Name FROM Production.ProductModel WHERE ProductModelID=122 or ProductModelID=119 FOR XML RAW, XMLSCHEMA ('urn:example.com') GO ``` This is the result: ``` ``` ## See Also [Use RAW Mode with FOR XML](../../relational-databases/xml/use-raw-mode-with-for-xml.md)