你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

Set statement

Applies to: ✅Microsoft FabricAzure Data ExplorerAzure MonitorMicrosoft Sentinel

The set statement is used to set a request property for the duration of the query.

请求属性控制查询的执行方式并返回结果。 它们可以是布尔标志(默认为 false),也可以是整数值。 一个查询可以包含零个、一个或多个 Set 语句。 Set 语句仅影响按程序顺序尾随这些语句的表格表达式语句。 必须用分号分隔任意两个语句。

请求属性不是 Kusto 查询语言的正式组成部分,可修改它,而不被视为中断性语言更改。

Note

Syntax

set OptionName [=OptionValue]

Learn more about syntax conventions.

Parameters

Name 类型 Required Description
OptionName string ✔️ 请求属性的名称。
OptionValue ✔️ 请求属性的值。

Example

此查询用于 query_take_max_records 限制从 StormEvents 表中检索到的记录数。 (这与使用 | take 100 运算符有点等效。

The examples in this article use publicly available tables in the help cluster, such as the StormEvents table in the Samples database.

The examples in this article use publicly available tables, such as the Weather table in the Weather analytics sample gallery. 可能需要修改示例查询中的表名称以匹配工作区中的表。

set query_take_max_records=100;
StormEvents

Output

该表显示前几个结果。

StartTime EndTime EpisodeId EventId State EventType
2007-01-15T12:30:00Z 2007-01-15T16:00:00Z 1636 7821 OHIO Flood
2007-08-03T01:50:00Z 2007-08-03T01:50:00Z 10085 56083 NEW YORK Thunderstorm Wind
2007-08-03T15:33:00Z 2007-08-03T15:33:00Z 10086 56084 NEW YORK Hail
2007-08-03T15:40:00Z 2007-08-03T15:40:00Z 10086 56085 NEW YORK Hail
2007-08-03T23:15:00Z 2007-08-05T04:30:00Z 6569 38232 NEBRASKA Flood
2007-08-06T18:19:00Z 2007-08-06T18:19:00Z 6719 39781 IOWA Thunderstorm Wind
... ... ... ... ... ...