Mixing tag types in the same query
- Last UpdatedMar 19, 2025
- 1 minute read
The History and Live tables use the sql_variant data type for the vValue column, allowing the return of various data types in a single column. In other words, these tables allow values for tags of different types to be retrieved with a simple query, without the need for a JOIN operation.
For example:
SELECT TagName, DateTime, vValue
FROM History
WHERE TagName IN ('SysTimeMin', 'SysPulse', 'SysString')
AND DateTime >= '2001-12-20 0:00'
AND DateTime <= '2001-12-20 0:05'
AND wwRetrievalMode = 'delta'
The results are:
|
TagName |
DateTime |
vValue |
|
SysTimeMin |
2001-12-20 00:00:00.000 |
0 |
|
SysPulse |
2001-12-20 00:00:00.000 |
0 |
|
SysString |
2001-12-20 00:00:00.000 |
2001/12/20 08:00:00 |
|
SysTimeMin |
2001-12-20 00:01:00.000 |
1 |
|
SysPulse |
2001-12-20 00:01:00.000 |
1 |
|
SysTimeMin |
2001-12-20 00:02:00.000 |
2 |
|
SysPulse |
2001-12-20 00:02:00.000 |
0 |
|
SysTimeMin |
2001-12-20 00:03:00.000 |
3 |
|
SysPulse |
2001-12-20 00:03:00.000 |
1 |
|
SysTimeMin |
2001-12-20 00:04:00.000 |
4 |
|
SysPulse |
2001-12-20 00:04:00.000 |
0 |
|
SysTimeMin |
2001-12-20 00:05:00.000 |
5 |
|
SysPulse |
2001-12-20 00:05:00.000 |
1 |