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

Querying Tables and Entities

Updated: February 26, 2015

Querying tables and entities in the Table service requires careful construction of the request URI. The following sections describe query options and demonstrate some common scenarios.

To return all of the tables in a given storage account, perform a GET operation on the Tables resource, as described in the Query Tables operation. The basic URI for addressing the Tables resource is as follows:


To return a single named table, specify that table as follows:


To return all entities in a table, specify the table name on the URI, without the Tables resource:


Query results are sorted by PartitionKey, then by RowKey. Ordering results in any other way is not currently supported.

You can specify additional options to limit the set of tables or entities returned, as described in the following Supported Query Options section.

The number of entities returned for a single request may be limited, if the query exceeds the maximum number of entities, exceeds the timeout interval, or crosses a partition boundary. For more information, see Query Timeout and Pagination.

The Table service supports the following query options, which conform to the OData Protocol Specification. You can use these options to limit the set of tables, entities, or entity properties returned by a query.


System query option Description


Returns only tables or entities that satisfy the specified filter.

Note that no more than 15 discrete comparisons are permitted within a $filter string.


Returns only the top n tables or entities from the set.


Returns the desired properties of an entity from the set. This query option is only supported for requests using version 2011-08-18 or newer. For more information, see Writing LINQ Queries Against the Table Service.

Additional query options defined by OData are not supported by the Table service.

Within a $filter clause, you can use comparison operators to specify the criteria against which to filter the query results.

For all property types, the following comparison operators are supported:


Operator URI expression













Additionally, the following operators are supported for Boolean properties:


Operator URI expression







For more information about filter syntax, see the OData Protocol Specification.

The following characters must be encoded if they are to be used in a query string:

  • Forward slash (/)

  • Question mark (?)

  • Colon (:)

  • 'At' symbol (@)

  • Ampersand (&)

  • Equals sign (=)

  • Plus sign (+)

  • Comma (,)

  • Dollar sign ($)

The following samples show how to construct the request URI for some typical entity queries using REST syntax. The same queries could be written using LINQ syntax. For more information, see Writing LINQ Queries Against the Table Service.

Note that both the $top and $filter options can be used to filter on table names as well, using the syntax demonstrated for filtering on properties of type String.

To return the top n entities for any query, specify the $top query option. The following example returns the top 10 entities from a table named Customers:


Because the PartitionKey and RowKey properties form an entity's primary key, you can use a special syntax to identify the entity, as follows:


Alternatively, you can specify these properties as part of the $filter option, as shown in the following section.

Note that the key property names and constant values are case-sensitive. Both the PartitionKey and RowKey properties are of type String.

When constructing a filter string, keep these rules in mind:

  • Use the logical operators defined by the OData Protocol Specification to compare a property to a value. Note that it is not possible to compare a property to a dynamic value; one side of the expression must be a constant.

  • The property name, operator, and constant value must be separated by URL-encoded spaces. A space is URL-encoded as %20.

  • All parts of the filter string are case-sensitive.

  • The constant value must be of the same data type as the property in order for the filter to return valid results. For more information about supported property types, see Understanding the Table Service Data Model.

Be sure to check whether a property has been explicitly typed before assuming it is of a type other than string. If a property has been explicitly typed, the type is indicated within the response when the entity is returned. If the property has not been explicitly typed, it will be of type String, and the type will not be indicated within the response when the entity is returned.

When filtering on string properties, enclose the string constant in single quotes.

The following example filters on the PartitionKey and RowKey properties; additional non-key properties could also be added to the query string.


The following example filters on a FirstName and LastName property:


Note that the Table service does not support wildcard queries. However, you can perform prefix matching by using comparison operators on the desired prefix. The following example returns entities with a LastName property beginning with the letter 'A':


To filter on an integer or floating-point number, specify the constant value on the URI without quotes.

This example returns all entities with an Age property whose value is greater than 30:


This example returns all entities with an AmountDue property whose value is less than or equal to 100.25:


To filter on a Boolean value, specify true or false without quotes.

The following example returns all entities where the IsActive property is set to true:


To filter on a DateTime value, specify the datetime keyword on the URI, followed by the date/time constant in single quotes. The date/time constant must be in combined UTC format, as described in Formatting DateTime Property Values.

The following example returns entities where the CustomerSince property is equal to July 10, 2008:


To filter on a GUID value, specify the guid keyword on the URI, followed by the guid constant in single quotes.

The following example returns entities where the GuidValue property is equal to :


See Also

© 2015 Microsoft