--- title: "Hiding Elements and Attributes by Using sql:hide | 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: - "hiding elements" - "element mapping [SQLXML], hiding attributes and elements" - "hide annotation" - "sql:hide" - "table/view mapping [SQLXML], hiding attributes and elements" - "table mapping [SQLXML], hiding attributes and elements" - "hiding attributes" - "annotated XSD schemas, hiding attributes and elements" - "attribute mapping [SQLXML], hiding attributes and elements" - "column mapping [SQLXML]" - "element hiding [SQLXML]" - "XSD schemas [SQLXML], hiding attributes and elements" - "attribute hiding [SQLXML]" ms.assetid: 0978301b-f068-46b6-82b9-dc555161f52e caps.latest.revision: 27 author: "douglaslMS" ms.author: "douglasl" manager: "jhubbard" --- # Hiding Elements and Attributes by Using sql:hide When an XPath query is executed against an XSD schema, the resulting XML document has elements and attributes that are specified in the schema. You can specify that some elements and attributes be hidden in the schema by using the **sql:hide** annotation. This is useful when the selection criteria of the query require particular elements or attributes in the schema, but you do not want them returned in the XML document that is generated. The **sql:hide** annotation takes a Boolean value (0=false, 1=true). The acceptable values are 0, 1, true, and false. ## 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:hide on an attribute The XSD schema in this example consists of an **\** element with **ContactID**, **FirstName**, and **LastName** attributes. The **\** element is of complex type and, therefore, maps to the table of the same name (default mapping). All the attributes of **\** element are of simple type and map to columns with the same names in the Person.Contacttable in the AdventureWorks database. In the schema, the **sql:hide** annotation is specified on the **ContactID** attribute. When an XPath query is specified against this schema, the **ContactID** is not returned in the XML document. ``` ``` ##### 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 Hide.xml. 2. Copy the following template and paste it into a text file. Save the file as HideT.xml in the same directory where you saved Hide.xml. ``` /Person.Contact[@ContactID="1"] ``` The directory path specified for the mapping schema (Hide.xml) is relative to the directory where the template is saved. An absolute path also can be specified, for example: ``` mapping-schema="C:\MyDir\Hide.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 4.0 Queries](../../relational-databases/sqlxml/using-ado-to-execute-sqlxml-4-0-queries.md). Here is the result set: ``` ``` When **sql:hide** is specified on an element, the element and its attributes or child elements do not appear in the XML document that is generated. Here is another XSD schema in which **sql:hide** is specified on the **\** element: ``` Sales.Customer-Sales.SalesOrderHeader-Sales.SalesOrderDetail Schema Copyright 2004 Microsoft. All rights reserved. ``` When an XPath query (for example `/Customers[@CID="1"]`) is specified against this schema, the XML document that is generated does not include the **\** element and its children, as shown in this partial result: ``` ```