Insert real-time original data
- Last UpdatedFeb 27, 2025
- 2 minute read
Real-time data insertion by means of an INSERT statement is supported for all non-I/O Server tags. Data that is acquired in this manner is handled just like real-time data coming from an I/O Server tag. You insert real-time data into history by specifying REALTIME for the value of the wwVersion parameter in a Transact-SQL INSERT statement. All data inserted as real-time data is assumed to be "original" data. "Original" data is the first data value that is stored for a particular timestamp.
Real-time data is always inserted into the current history block and incorporated into the primary (real-time) data stream. This eliminates the performance overhead that is associated with inserting and/or versioning non-real-time data, thus making the inserts very efficient.
For example, you can create a client application that uses Transact-SQL INSERT statements to insert real-time data into the system.
The following restrictions apply to a real-time insert.
-
You cannot insert real-time data for an I/O Server tag.
-
You must have SQL Server permissions to perform an insert.
In the following example, a value is inserted for 'MyAnalogTag1' directly into the primary data stream. The timestamp for the value is determined by the result of the getdate() function:
INSERT INSQL.Runtime.dbo.AnalogHistory (DateTime, TagName, Value, OPCQuality, wwVersion)
VALUES(getdate(), 'MyAnalogTag1', 10, 192, 'REALTIME')
You can also allow the system to timestamp the value by specifying a NULL value for the DateTime column. The timestamp is the current time of the Historian. For example:
INSERT INSQL.Runtime.dbo.AnalogHistory (DateTime, TagName, Value, OPCQuality, wwVersion)
VALUES(null, 'MyAnalogTag1', 10, 192, 'REALTIME')
Note that this is a special case that is supported by the REALTIME parameter; under normal circumstances a NULL value for the DateTime column produces an error.