Supported SET Statement Syntax

The use of SET statements is not mandatory, since query parameters can also be specified in a WHERE clause. However, SET statements can make your queries more readable. By using SET statements. you can save time by simplifying SELECT queries, because you do not have to retype query parameters each time you issue a new SELECT statement. The SET parameters persist for the entire session.

With a SET statement you can define various defaults for your queries to use, such as:

  • The starting date and time of the selected data
  • The ending date and time
  • The calculation mode
  • The number of rows returned
  • The data sampling mode

For more information, see ihQuerySettings Table.

When entering numbers, do not use a thousands separator. For example, if you were setting a collection interval to 7,000 milliseconds, the following statement would be correct.

Example: Correct SET Without Comma to Separate Thousands Place

SET IntervalMilliseconds = 7000

Multiple SET statements in the same command are not supported. Combine multiple variables in the same SET statement.

Incorrect

For instance, improper SET statements would be:

SET starttime=yesterday-10d
SET endtime=today
SET samplingmode=interpolated

Correct

The correct way of writing the above SET statement is as follows:

SET starttime=yesterday-10d, endtime=today, samplingmode=interpolated