IMD SolutionComputing LibraryShop main store

Troubleshooting

Why historian tags don't prove a Galaxy object still exists

Edge computing and IIoT Published 5 min read

Short answer

A tag found in dbo._Tag or dbo._TagExtendedProperty proves only that stored metadata matched your filters: renames and deletes are never echoed to the historian. Approximate current existence with recent good data, excluding QualityDetail = 24 while the Engine's disconnect marking stays at its default, then cross-check a Galaxy attribute query that returns deployed and undeployed attributes alike.

On this page
  1. What a metadata match actually proves
  2. The two quality values and what they filter
  3. The query pattern that approximates existence
  4. Worked example: '#PV' tags in one Area on a two-day cutoff
  5. Cross-check with the Galaxy attribute query
  6. Reading the combined result
  7. Questions asked

A tag that appears in dbo._Tag or dbo._TagExtendedProperty proves only that the historian's stored metadata matched your name and Area filters. Renames and deletes in the Galaxy are never echoed to the historian, so those tables return every tag that ever logged, including objects removed years ago. The closest approximation to "still exists" is recent good data — a timestamp cutoff plus QualityDetail <> 24, valid while the Engine's disconnect marking stays at its default — cross-checked against a Galaxy attribute query that itself lists deployed and undeployed attributes. The query you are using joins dbo.History on OPCQuality = 192 with no timestamp condition, so years-old good rows from deleted tags pass it.

What a metadata match actually proves #

The metadata tables are the historian's catalog of everything that has ever stored data there. Keeping retired entries is normal behavior, not corruption: the catalog is what keeps history from deleted objects queryable. A LIKE match on the tag name and a match on the location property therefore select from the full historical catalog, not from the set of objects currently in the IDE.

Historian metadata answers "what was configured", never "what is alive" — the same gap that appears when historian configuration shows only system tags instead of the tags you expect. Existence has to come from somewhere else.

Two details of the location filter are worth settling while you are in there. The property is selected by key, PropertyNameKey = '3'; another common form of the same query identifies it by name, Location. Confirm which representation your database actually holds before treating them as interchangeable, and keep the CAST(tep.PropertyValue AS NVARCHAR) the original SQL uses, because the property is not stored as text.

The two quality values and what they filter #

OPCQuality = 192 is the good-quality value. It tells you a row was valid when it was written; it says nothing about when. Every row a tag ever produced can pass that filter, which is why a join on quality alone keeps returning deleted tags.

QualityDetail = 24 is the more useful marker: rows written for undeployed objects carry it, but only while the Engine setting "Reconnect as soon as possible & do not mark disconnects" remains unchecked, its default. Inspect that setting before relying on the exclusion; if it has been checked, disconnects stop being marked and recency becomes your only signal.

A good quality flag on a row that is nevertheless stale is its own failure pattern — the one behind troubleshooting OPC UA tag staleness with good quality in an OPC UA context. Quality and timestamp answer different questions, and this check needs both.

The query pattern that approximates existence #

Build the list from five conditions:

  • name contains the target substring: tep.TagName LIKE '%#PV%'
  • location property selected by key: tep.PropertyNameKey = '3'
  • Area contains the parameter: CAST(tep.PropertyValue AS NVARCHAR) LIKE '%' + @Areaname + '%'
  • recency: an EXISTS row in dbo.History newer than a cutoff
  • quality on that row: OPCQuality = 192 and QualityDetail <> 24

Pass @Areaname as a parameter and run all of this read-only against the runtime and Galaxy databases; both are vendor-managed.

The recency condition is what does the existence work: an object that was undeployed, renamed or deleted stops producing rows under its old tag name. Its weakness is the quiet tag — a setpoint nobody has touched inside the window has no recent row even though the object is alive. Pick the window longer than the longest silent stretch you will tolerate, and widen it before declaring a quiet tag dead.

Worked example: '#PV' tags in one Area on a two-day cutoff #

Inputs:

  • name substring #PV, contains-match
  • Area passed as the parameter @Areaname
  • location property keyed PropertyNameKey = '3'
  • recency window: two days, the window this pattern ships with, adjustable
  • Engine disconnect marking at its default, so the QualityDetail <> 24 exclusion is meaningful

Rule in words: a tag counts as currently existing when it has at least one dbo.History row newer than the cutoff that is good and not marked 24.

Arithmetic: two days × 24 h per day = 48 h, so the cutoff is GETDATE() minus 48 hours.

DECLARE @Cutoff DATETIME = DATEADD(HOUR, -48, GETDATE());

SELECT DISTINCT
       tep.TagName AS Tag,
       CAST(tep.PropertyValue AS NVARCHAR) AS AreaLocation
FROM [Runtime].[dbo].[_TagExtendedProperty] AS tep
WHERE tep.TagName LIKE '%#PV%'
  AND tep.PropertyNameKey = '3'
  AND CAST(tep.PropertyValue AS NVARCHAR) LIKE '%' + @Areaname + '%'
  AND EXISTS (SELECT 1
              FROM dbo.History AS his
              WHERE his.TagName = tep.TagName
                AND his.DateTime >= @Cutoff
                AND his.OPCQuality = 192
                AND his.QualityDetail <> 24)
ORDER BY Tag;

Before trusting the result, validate it against one tag you know is live — a PV you can watch change in the IDE — and confirm it appears. Everything returned is your active list. What matters more is what is not returned: any tag present in the metadata filter but absent here is a candidate for deleted, renamed or merely quiet.

Decision, with its thresholds: two days is the right window for anything that moves at least daily. A tag absent at two days that the Galaxy cross-check below cannot find is deleted or renamed — drop it. A tag the Galaxy still has is quiet, not gone: widen to 30 days × 24 h = 720 h, DATEADD(HOUR, -720, GETDATE()), and re-run. A setpoint touched monthly will not show inside 30 days even when healthy, so keep it on the list flagged for manual confirmation rather than dropping it.

Cross-check with the Galaxy attribute query #

The Galaxy side cannot tell you what is logging, but it can tell you what is configured. The query joins dbo.gobject to dbo.primitive_instance on gobject_id, then dbo.primitive_definition on primitive_definition_id with primitive_name <> '', and finally dbo.package on the package id; it selects g.tag_name + '.' + p.primitive_name plus the ids p.gobject_id, p.package_id and p.mx_primitive_id. The scope filters in the original are:

  • p.execution_group = 18
  • g.is_template = 0
  • g.namespace_id = 1

Those three values belong to the query as supplied; confirm they match the scope you mean before reusing them. The result lists attributes with history enabled, deployed and undeployed alike — its own stated caveat — so treat it as a candidate inventory and existence cross-check, never as a runtime status list.

Reading the combined result #

Observation What it establishes Action
Tag in the recent-data result and in the Galaxy list Configured and currently writing Keep it
Tag in metadata, absent from recent data, absent from the Galaxy list Deleted or renamed Drop it from the active list
Tag absent from recent data, present in the Galaxy list Undeployed or quiet Widen the window; setpoints get manual confirmation
Attribute in the Galaxy list, never in historian metadata History configured but nothing stored Check that the attribute's history actually started

Wrap the query as a stored procedure with @Areaname and the cutoff in hours as parameters, and you have the "currently existing" list the raw tables cannot give you — an approximation, but a bounded and repeatable one.

Questions asked

If an object was renamed, what happens to its historian tag?

The old tag stops receiving data but keeps its metadata and all stored history, and the renamed object's attribute writes under the new name. Your name filter can therefore match both an orphaned old tag and a live new one at the same time. The recent-data condition drops the orphan automatically, which is exactly why it, not the metadata tables, is the existence test.

Can I clean the stale tags out of dbo._Tag instead of filtering?

No. Those tables are written and maintained by the historian itself, and editing them directly is not a supported cleanup: queries against stored history depend on the metadata staying consistent with it. Do the filtering at query time, in a view or stored procedure, and leave the underlying rows alone. If the filtered list is the deliverable, materialize it into your own reporting table rather than modifying the historian's.

Why does my result list change size between runs?

Because membership depends on when each tag last wrote a row, and that follows the logging mode. A deadband-logged analog value writes only on change, a time-based tag writes on interval, and buffering or retention can delay or remove rows. A tag that crossed its deadband just after your cutoff appears on the next run. Expect small movement between runs and pick a window longer than the slowest quiet period you will tolerate.

Is there a quick way to see how stale each tag is?

Yes: aggregate instead of joining. SELECT TagName, MAX(DateTime) FROM dbo.History GROUP BY TagName returns each tag's newest stored row in one pass; keep only tags whose newest row is newer than your cutoff. That shows the age of every tag, which a pass/fail exists-check hides, and turns choosing the window into an informed decision rather than a guess.

How do I keep the Area value safe in the stored procedure?

Pass it as a parameter and build the pattern inside SQL Server, never in application-assembled SQL text: CAST(tep.PropertyValue AS NVARCHAR) LIKE '%' + @Areaname + '%'. Escape LIKE wildcards in the input if an Area name can contain % or _, and remember the match is contains-style, not exact equality, so an Area of Packaging also matches Packaging 2.

Keep reading

  • Troubleshooting

    Why an Easy Chart pen shows no historian data

    A live tag with an empty Easy Chart pen is a historian write-path fault, not a tag fault. Clear the SQL Server no count option first; if it is already off, remove the trigger or procedure statement that makes the update return a result set, then let the store-and-forward cache drain.

    Edge computing and IIoT

  • How-to

    Downsampling old Ignition historian data to one-minute averages

    Ignition has no built-in expiry with aggregation, so you downsample stored history yourself. Two workable patterns: a scheduled database job that keeps the first row of each 60,000 ms bucket in the old sqlt_data partitions, or a monthly gateway script that reads averages or min/max with system.tag.queryTagHistory and then deletes the raw rows. Both are irreversible deletes, so run them on a verified backup and tighten per-tag deadbands first.

    Edge computing and IIoT

  • Troubleshooting

    Historian tagnames showing a ? prefix mean hidden spaces

    A ? prefix on a tagname in an aahDBDump export marks a hidden space-type character in the stored name, not a corrupt tag or lost history. Find every affected tag with a CHARINDEX query on dbo.Tag in the Runtime database, then rename them with the aahTagRename utility (TN Hist235), which preserves history and needs Historian stopped and disabled under store-and-forward protection.

    Edge computing and IIoT