Prevent losing history data when the tag name is changed

Hi

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.

2 Likes

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
6 Likes

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.

3 Likes

Hii,

It's not worked, replace the old tagpath with new tagpath. Enabled the tag and it's logged on interval basis.I tried so many times, but every time the new id created in sqlte table.

update for_test.sqlth_te 
set tagpath =   "name  test tagss/ramp4" 
where tagpath = "name  test tags/ramp4"

id no.1 to 4 old tagpath name name test tags/ramp0 replaced by new tagpath name test tagss/ramp0. All ID tag paths have been renamed. When the tag is enabled and data logging started, a new ID is generated as ID number 5 to 8 and data logged with this new id number.

Data not logged in old id number.(ID 1 to 4)