Making and querying annotations
- Last UpdatedMar 19, 2025
- 1 minute read
The following query creates an annotation for the specified tag. The annotation is made in response to a pump turning off. Then, the annotations for a particular tag are returned.
DECLARE @@UserKey INT
SELECT @@UserKey = UserKey
FROM UserDetail
WHERE UserName = 'wwAdmin'
INSERT INTO Annotation (TagName, UserKey, DateTime, Content)
VALUES ('ReactLevel', @@UserKey, GetDate(), 'The Pump is off')
SELECT DateTime, TagName, Content
FROM Annotation
WHERE Annotation.TagName = 'ReactLevel'
AND DateTime > '27 Feb 01'
AND DateTime <= GetDate()
The results are:
|
DateTime |
TagName |
Content |
|
2001-02-28 19:18:00.000 |
ReactLevel |
The Pump is off |
|
(1 row(s) affected) |