--- title: "Creating Constant Elements Using sql:is-constant (SQLXML 4.0) | Microsoft Docs" ms.custom: "" ms.date: "03/16/2017" ms.prod: "sql-server-2016" ms.reviewer: "" ms.suite: "" ms.technology: - "dbe-xml" ms.tgt_pltfrm: "" ms.topic: "reference" helpviewer_keywords: - "element does not map [SQLXML]" - "sql:is-constant" - "XSD schemas [SQLXML], constant elements" - "element mapping [SQLXML], constant elements" - "is-constant annotation" - "constant elements [SQLXML]" - "annotated XSD schemas, constant elements" ms.assetid: 940eea1b-54f5-445f-b844-c894d9f3941b caps.latest.revision: 27 author: "douglaslMS" ms.author: "douglasl" manager: "jhubbard" --- # Creating Constant Elements Using sql:is-constant (SQLXML 4.0) To specify a constant element—that is, an element in the XSD schema that does not map to any database table or column—you can use the **sql:is-constant** annotation. This annotation takes a Boolean value (0 = false, 1 = true). The acceptable values are 0, 1, true, and false. The **sql:is-constant** annotation can be specified on an element that does not have any attributes. If it is specified on an element with the value true (or 1), that element is not mapped to the database but still appears in the XML document. The **sql:is-constant** annotation can be used for: - Adding a top-level element to the XML document. XML requires a single top-level element (root element) for the document. - Creating container elements, such as an **\** element that wraps all orders. The **sql:is-constant** annotation can be added to a **\** element. ## Examples To create working samples using the following examples, you must meet certain requirements. For more information, see [Requirements for Running SQLXML Examples](../../relational-databases/sqlxml/requirements-for-running-sqlxml-examples.md). ### A. Specifying sql:is-constant to add a container element In this annotated XSD schema, **\** is defined as a constant element by specifying the **sql:is-constant** attribute with a value of 1. Therefore, **\** is not mapped to any database table or column. This constant element consists of the **\** child elements. Although **\** does not map to any database table or column, it still appears in the resulting XML as a container element containing the **\** child elements. ``` ``` ##### To test a sample XPath query against the schema 1. Copy the schema code above and paste it into a text file. Save the file as isConstant.xml. 2. Copy the following template and paste it into a text file. Save the file as isConstantT.xml in the same directory where you saved isConstant.xml. ``` Customer[@CustomerID=1] ``` The directory path specified for the mapping schema (isConstant.xml) is relative to the directory where the template is saved. An absolute path also can be specified, for example: ``` mapping-schema="C:\MyDir\isConstant.xml" ``` 3. Create and use the SQLXML 4.0 Test Script (Sqlxml4test.vbs) to execute the template. For more information, see [Using ADO to Execute SQLXML Queries](../../relational-databases/sqlxml/using-ado-to-execute-sqlxml-4-0-queries.md). This is the partial result set: ``` ... ```