Prevent losing history data when the tag name is changed


Sometimes, we have to change the tag folder name after a long time and we have a lot of history.
Unfortunately, this act causes the new tag Id is created in the "sqlth_te" table and the old name to be marked as retired so we lost our data.

I believe this action is only correct if the user deletes the tags, but when he changes the tag name the only thing that should be updated is the tagPath in the "sqlth_te" table and not flag it as retired.

So I wonder if other people suffer from this problem and if is there any workaround for this.

1 Like

Lots of people suffer from this. It has been this way from the beginning. The DB structure is public, so those who care update the DB themselves. Not exactly trivial, but not rocket science.

Users also suffer when a tag is moved to a different folder. Not as simple a fix.


Here is what I do:

  1. disable the tag (not the history) you need to move or rename
  2. move and/or rename the tag
  3. open the database query browser tool and rename the tagpath in the tagpath column:
update sqlth_te 
set tagpath = "your new tagpath" 
where tagpath = "your old tagpath"
  1. enable the tag

Good trick thanks.
The problem is I have 12000 tags which divide into 24 stations and I need to change the station name.

Disable them all.
Use a SQL workbench to run something like

Update sqlth_te
Set tagpath = concat('[provider]new/station/prefix/', right(tagpath, len(tagpath) - ..len of old prefix..))
Where tagpath like '[provider]old/station/prefix/%'

Re-enable them all.

1 Like