Use OPENQUERY to Access a Linked Server

The following examples show how to use OPENQUERY to access the Historian OLE DB Provider as a linked server in Microsoft SQL Server. Be sure that you configure the linked server as described in Configuring the Historian OLE DB Provider as a Linked Server before using any of the examples.

Note: You cannot use OPENQUERY to access the ihTrend table. Use four-part name syntax to access the ihTrend table.

Example 1: Return a List of Tags From Historian

SELECT * FROM OPENQUERY(iHist,'SELECT * FROM ihTags')

Example 2: Use a Complex Query to Extract Values From Historian

SELECT TagName, TimeStamp, Value, Quality FROM OPENQUERY (iHist,'
SET
StartTime=yesterday-12Day, EndTime=Today, IntervalMilliseconds=1Hour, SamplingMode=Calculated, CalculationMode=Maximum
SELECT * FROM ihRawData WHERE TagName LIKE *simulation00001')