# Prevent losing history data when the tag name is changed

**URL:** <https://forum.inductiveautomation.com/t/prevent-losing-history-data-when-the-tag-name-is-changed/72493>\
**Category:** Ignition\
**Created:** [April 16, 2023, 12:23pm UTC](https://forum.inductiveautomation.com/t/prevent-losing-history-data-when-the-tag-name-is-changed/72493 "2023-04-16T12:23:28Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![nader.chinichian](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nader.chinichian/32/9261_2.png) [@nader.chinichian](https://forum.inductiveautomation.com/u/nader.chinichian)\
**Post date:** [April 16, 2023, 12:23pm UTC](https://forum.inductiveautomation.com/t/prevent-losing-history-data-when-the-tag-name-is-changed/72493/1 "2023-04-16T12:23:28Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [April 16, 2023, 12:45pm UTC](https://forum.inductiveautomation.com/t/prevent-losing-history-data-when-the-tag-name-is-changed/72493/2 "2023-04-16T12:45:00Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jay](https://avatars.discourse-cdn.com/v4/letter/j/ed8c4c/32.png) [@jay](https://forum.inductiveautomation.com/u/jay)\
**Post date:** [April 16, 2023, 5:24pm UTC](https://forum.inductiveautomation.com/t/prevent-losing-history-data-when-the-tag-name-is-changed/72493/3 "2023-04-16T17:24:28Z")

</div>

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:

```auto
update sqlth_te 
set tagpath = "your new tagpath" 
where tagpath = "your old tagpath"

```

1. enable the tag

---

<div class="post-metadata">

**Author:** ![nader.chinichian](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nader.chinichian/32/9261_2.png) [@nader.chinichian](https://forum.inductiveautomation.com/u/nader.chinichian)\
**Post date:** [April 16, 2023, 6:49pm UTC](https://forum.inductiveautomation.com/t/prevent-losing-history-data-when-the-tag-name-is-changed/72493/4 "2023-04-16T18:49:42Z")

</div>

> [@jay](#):
>
> column

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

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [April 16, 2023, 7:22pm UTC](https://forum.inductiveautomation.com/t/prevent-losing-history-data-when-the-tag-name-is-changed/72493/5 "2023-04-16T19:22:19Z")

</div>

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

```auto
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.

---

<div class="post-metadata">

**Author:** ![Govind\_Suthar1](https://avatars.discourse-cdn.com/v4/letter/g/a87d85/32.png) [@Govind\_Suthar1](https://forum.inductiveautomation.com/u/Govind_Suthar1)\
**Post date:** [September 27, 2024, 10:45am UTC](https://forum.inductiveautomation.com/t/prevent-losing-history-data-when-the-tag-name-is-changed/72493/6 "2024-09-27T10:45:17Z")

</div>

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.

```python
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)

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/4/d4418f3428d0c0a0dfe6bfbbaaf9759b14e000b1.png)
