Skip to main content
InSource Solutions

TN Hist288 Listing unused Historian tags




This article from InSource shows how to get a list of tags that are no longer being Historized in the Wonderware Historian.  This may happen as a system grows over the years and objects (and tags get renamed).  This article assumes the user is using Application Server.

  • Author: Lewis Talley
  • Published: 03/14/2018
  • Applies to: Historian  + AppServer (various)


I first query the GR DB for a list of all objects being historized and combine it in a format similar to how it is represented in the historian (see below)


Agitator_005 (object) AuxContact (attribute)



The first part of the query simply combines this in a temp table which will be used later in the query.

Then we compare the results against a query to the historian, by doing a RIGHT JOIN to return a list of tags in the Historian that do not match with object references in the GR.  Basically, we produce a list that the Historian "thinks" is being historized, but in reality is not.  The complete query is below:


Select Distinct (g.Tag_Name  + '.' + p.Primitive_Name) as 'History TagName' into #TempTable

from Primitive_Instance p  

Join gobject g

                on g.gobject_id = p.gobject_id 

Where  p.Extension_Type = 'HistoryExtension'

  and g.Is_template <> 1  


select h.TagName

from #TempTable t

Right JOIN [Historian].[Runtime].[dbo].[Tag] h

                on  t.[History TagName] = h.Tagname

Where t.[History TagName] is null