.set stored_query_result command

Sets a mechanism that stores a query result on the service for up to 24 hours.

If a stored query result name already exists, .set fails. Instead, use .set-or-replace, which deletes the existing stored query result and creates a new one with the same name.

Permissions

You must have Database Viewer permissions to run these commands.

Syntax

.set [async] stored_query_result StoredQueryResultName [with (PropertyName = PropertyValue [, ...])] <| Query

.set-or-replace [async] stored_query_result StoredQueryResultName [with (PropertyName = PropertyValue [, ...])] <| Query

Learn more about syntax conventions.

Parameters

Name Type Required Description
async string If specified, the command will return and continue ingestion in the background. Use the returned OperationId with the .show operations command to retrieve the ingestion completion status and results.
StoredQueryResultName string ✔️ Stored query result name that adheres to entity names rules.
PropertyName, PropertyValue string One or more supported properties.
Query string ✔️ The text of a query whose results will be stored.

Supported properties

Property Type Description
expiresAfter timespan Determines when the stored query result expires. Maximum is 24 hours.
previewCount int The number of rows to return in a preview. Setting this property to 0 (default) makes the command return all the query result rows. The property is ignored when the command is invoked using async mode.

Returns

A tabular subset of the records produced by the query, referred to as the "preview", or all records. Regardless of how many records are shown on return, all records are stored.

Character limitation

The command fails if the query generates an entity name with the $ character. The entity names must comply with the naming rules, so the $ character must be removed for the ingest command to succeed.

For example, in the following query, the search operator generates a column $table. To store the query results, use project-rename to rename the column.

.set stored_query_result Texas <| search ['State']:'Texas' | project-rename tableName=$table

Examples

The following example creates a stored query result named Numbers.

.set stored_query_result Numbers <| range X from 1 to 1000000 step 1

Output

X
1
2
3
...