SET Statements and Variables Examples

If you do not change any variables using the SET statement or a WHERE clause in your SELECT statement, the default session variables are considered. For instance, if you do not specify a start and end time for your collected data, the data output from a SELECT statement will be the last two hours prior to execution of the query.

For example, if you want to SELECT all of the messages from the ihMessages table for the last day, you must explicitly state that you want the messages from the last day in the query. Otherwise, only the messages from the last two hours are displayed when you run the query, since that is the default setting.

SET statement variables persist during a session until changed. You can combine the SET statement on the same line as the SELECT statement.

Perform a Simple SET

SET samplingmode=currentvalue

Perform Multiple SETs

SET starttime='14-sep-2001 11:00:00', endtime='14-sep-2001 12:00:00', 
samplingmode=interpolated, intervalmilliseconds=

Prepare for a RawByTime Query

SET starttime='14-sep-2001 11:00:00', endtime='14-sep-2001 12:00:00', 
samplingmode=rawbytime

Prepare for a RawByNumber Query

SET starttime='14-sep-2001 11:00:00', samplingmode=rawbynumber, 
numberofsamples=10, direction=backward

Prepare for One Hour Minimums

SET starttime='15-sep-2001 00:00:00', endtime='16-sep-2001 00:00:00', 
samplingmode=calculated, intervalmilliseconds=36

Prepare for a Filtered Data Query

SET starttime='14-sep-2001 11:00:00', endtime='14-sep-2001 12:00:00', 
samplingmode=current, filtertag='MY_SERVER.simul

Throttle Results with a SET Statement

SET ROWCOUNT = 4
SELECT Tagname FROM ihTags