# Merge old tag history with rename new tag history

**URL:** <https://forum.inductiveautomation.com/t/merge-old-tag-history-with-rename-new-tag-history/66157>\
**Category:** Ignition\
**Tags:** ignition81\
**Created:** [November 5, 2022, 2:16am UTC](https://forum.inductiveautomation.com/t/merge-old-tag-history-with-rename-new-tag-history/66157 "2022-11-05T02:16:32Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![taohongyu88](https://avatars.discourse-cdn.com/v4/letter/t/f05b48/32.png) [@taohongyu88](https://forum.inductiveautomation.com/u/taohongyu88)\
**Post date:** [November 5, 2022, 2:16am UTC](https://forum.inductiveautomation.com/t/merge-old-tag-history-with-rename-new-tag-history/66157/1 "2022-11-05T02:16:32Z")

</div>

Ignition Version 8.1.2  
I create a tag and config it history. SQL ID is 5051.  
Later I rename this tag on 2022-10-19 . SQL ID is 5188.  
When I query Chart ,I just see the new tag chart.  
I can't query the old tag and rename new tag chart together.  
How to merge them together?

 ![1667614117918](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/a/3afac878507d050e9db46784fedf030c463a4f5c.png)

 ![1667614073456](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/7/b724a205cc4fd71eaa5f6c284549cb4f42d528bf.png)

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/5/b57ff7a2cae6488a7f024d27ba09d5112c554c98.png)

---

<div class="post-metadata">

**Author:** ![Munkhbat\_Munkhtulga](https://avatars.discourse-cdn.com/v4/letter/m/958977/32.png) [@Munkhbat\_Munkhtulga](https://forum.inductiveautomation.com/u/Munkhbat_Munkhtulga)\
**Post date:** [November 14, 2022, 9:56pm UTC](https://forum.inductiveautomation.com/t/merge-old-tag-history-with-rename-new-tag-history/66157/2 "2022-11-14T21:56:17Z")

</div>

Hi taohongyu88,

Please reach out to support regarding merging old tag history with new tag history. You can reach us here [Support Home Page | Inductive Automation](https://www.inductiveautomation.com/support/home/)

Best,

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [November 15, 2022, 3:17am UTC](https://forum.inductiveautomation.com/t/merge-old-tag-history-with-rename-new-tag-history/66157/3 "2022-11-15T03:17:18Z")

</div>

To be fair, merging of tag history due to a rename or move shouldn't require support to help with this. This should really be something that can easily be done by an integrator.

**Edit: the below advice, while it works, is incredibly inefficient. It’s the tag table sqlth\_te table which should be edited, not the individual data tables.**

@taohongyu88 you just need to change the tagid of all of the relevant records in your sqlth\_data\_x tables to the new tag id.  
PS. If the above doesn't make sense and you don't know what you're doing in SQL, you could end up destroying _all_ of your tag history. In which case a support call _is_ probably recommended.

E.g.  
For:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/2/f28b597dc2dcc7e15481154a51205c114ef9dc59.png)

Execute this below to re-map your old history to the new tag:

```python
UPDATE
	sqlt_data_5_2022_11
SET
	tagid = 5262
WHERE
	tagid = 5261

```

_ **ENSURE YOU HAVE A "WHERE" CLAUSE AND THAT IT IS CORRECT** _ before executing that UPDATE query  
Excluding a WHERE clause will re-map _all_ history in that table to your new tag.  
Using the wrong WHERE clause may have equally catastrophic consequences

---

<div class="post-metadata">

**Author:** ![taohongyu88](https://avatars.discourse-cdn.com/v4/letter/t/f05b48/32.png) [@taohongyu88](https://forum.inductiveautomation.com/u/taohongyu88)\
**Post date:** [June 1, 2024, 8:53am UTC](https://forum.inductiveautomation.com/t/merge-old-tag-history-with-rename-new-tag-history/66157/4 "2024-06-01T08:53:19Z")

</div>

> [@nminchin](#):
>
> before executing that UPDATE query  
> Excluding a WHERE clause will re-map _all_ history in that table to your new tag.  
> Using the wrong WHERE clause may have equally catastrophic consequences

I find a new question.  
When I update old tag's tagid to new tag's tagid ;  
PowerChart show this month's history ,but not show the last month's history?

[Power Chart not show the rename tag's last month History? - Ignition - Inductive Automation Forum](https://forum.inductiveautomation.com/t/power-chart-not-show-the-rename-tags-last-month-history/91236)

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [June 2, 2024, 7:49am UTC](https://forum.inductiveautomation.com/t/merge-old-tag-history-with-rename-new-tag-history/66157/5 "2024-06-02T07:49:29Z")

</div>

> [@taohongyu88](#):
>
> When I update old tag's tagid to new tag's tagid

I assume you mean when you updated history for the old tag's history to point to the new tagid?

---

<div class="post-metadata">

**Author:** ![taohongyu88](https://avatars.discourse-cdn.com/v4/letter/t/f05b48/32.png) [@taohongyu88](https://forum.inductiveautomation.com/u/taohongyu88)\
**Post date:** [June 3, 2024, 12:57am UTC](https://forum.inductiveautomation.com/t/merge-old-tag-history-with-rename-new-tag-history/66157/6 "2024-06-03T00:57:23Z")

</div>

Yeah！ Thank you.  
In Database -Table-sqlth\_te , must Update created time to the old tag's created time.  
`update sqlth_te set created ='1716865518209' where tagid=7443`

---

<div class="post-metadata">

**Author:** ![Anderson\_Suarez](https://avatars.discourse-cdn.com/v4/letter/a/71e660/32.png) [@Anderson\_Suarez](https://forum.inductiveautomation.com/u/Anderson_Suarez)\
**Post date:** [September 10, 2025, 2:42pm UTC](https://forum.inductiveautomation.com/t/merge-old-tag-history-with-rename-new-tag-history/66157/7 "2025-09-10T14:42:09Z")

</div>

Hello,

I would like to add a comment here since “Merge History Ignition” finds this thread on search engines.

It is a possible client ask to rename tags in the historian but keep the history. This is a way that you can deal with such a request:

- Copy the UDTs or tags to JSON and edit the names so that the configuration is identical.
  - To avoid recording new data you must disable any new historical points before creating the tag. Or nminchin’s SQL update will run into an error code due to duplicates.
  - See below for another SQL query that can ignore duplicate entries

- Go on the database browser and find the new tag id and old tagid as nminchin pointed out “where tagpath like ‘%your tag here%’
- Then this is the tricky step. Since you will have new history on the newly created point the sql query will find duplicates. This is how you can avoid it:  
`UPDATE sqlt_data_5_2022_11 AS old`  
`LEFT JOIN sqlt_data_5_2022_11 AS new`  
`ON new.tagid = 5262 AND new.t_stamp = old.t_stamp`  
`SET old.tagid = 5262`  
`WHERE old.tagid = 5261`  
`AND new.tagid IS NULL;`
- If instead you would like to ‘copy’ the history over and not just edit the tagid, then this can be done:

`INSERT INTO sqlt_data_5_2022_11 (t_stamp, intvalue, floatvalue, stringvalue, datatype, tagid)`  
`SELECT old.t_stamp, old.intvalue, old.floatvalue, old.stringvalue, old.datatype, 5262`  
`FROM sqlt_data_5_2022_11 AS old`  
`LEFT JOIN sqlt_data_5_2022_11 AS existing`  
`ON existing.tagid = 5262 AND existing.t_stamp = old.t_stamp`  
`WHERE old.tagid = 5261`  
`AND existing.tagid IS NULL;`

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [September 10, 2025, 9:53pm UTC](https://forum.inductiveautomation.com/t/merge-old-tag-history-with-rename-new-tag-history/66157/8 "2025-09-10T21:53:22Z")

</div>

Oh, I didn't realise this was still here. The simpler and significantly faster option is actually the reverse. Instead of updating the data tables, update the tagpaths in the tag table, modifying the old tag paths to the new tag paths. Then you're updating a single table of 1000's of records instead of 10's of tables of billions of records

---

<div class="post-metadata">

**Author:** ![Anderson\_Suarez](https://avatars.discourse-cdn.com/v4/letter/a/71e660/32.png) [@Anderson\_Suarez](https://forum.inductiveautomation.com/u/Anderson_Suarez)\
**Post date:** [September 10, 2025, 10:11pm UTC](https://forum.inductiveautomation.com/t/merge-old-tag-history-with-rename-new-tag-history/66157/9 "2025-09-10T22:11:15Z")

</div>

yes haha… what if you wanna copy

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [September 11, 2025, 6:12am UTC](https://forum.inductiveautomation.com/t/merge-old-tag-history-with-rename-new-tag-history/66157/10 "2025-09-11T06:12:09Z")

</div>

If you want a copy then backup the table data 🙂

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [September 11, 2025, 9:39am UTC](https://forum.inductiveautomation.com/t/merge-old-tag-history-with-rename-new-tag-history/66157/11 "2025-09-11T09:39:32Z")

</div>

And set `retired` to `null`, and restart the historian to rebuild its cache or you'll end up recreating a tag entry when the tag's value changes.  
You may also want to delete the obsolete tag entry. Or not, your pick.

---

<div class="post-metadata">

**Author:** ![Anderson\_Suarez](https://avatars.discourse-cdn.com/v4/letter/a/71e660/32.png) [@Anderson\_Suarez](https://forum.inductiveautomation.com/u/Anderson_Suarez)\
**Post date:** [September 12, 2025, 5:16pm UTC](https://forum.inductiveautomation.com/t/merge-old-tag-history-with-rename-new-tag-history/66157/12 "2025-09-12T17:16:28Z")

</div>

Hey, the only issue I had when copying history from one tagid to a brand new tagid is that in the power chart the new tag would not show old manually inserted data. Even if inserted with the supported Ignition python API the old data would not appear on the PowerChart.

To fix this I edited the ‘created’ timestamp of the brand new tag. Making it appear as it it were created months ago. Now the Power Chart graphs the data appropriately.

Backing up the table data is not what I’m after, but rather copying a tag and moving its history with it. Or renaming a tag and moving the history of the last tagpath name onto in. (Although in that case it’s likely that changing the name in the sqlth\_te table would work)

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [September 12, 2025, 5:41pm UTC](https://forum.inductiveautomation.com/t/merge-old-tag-history-with-rename-new-tag-history/66157/13 "2025-09-12T17:41:25Z")

</div>

It “works”, with some quirks. I know first hand, as I had a similar requirement.  
If you rename a tag in `sqlth_te`, it works just fine… but if the tag with the new name receives data, it will create a new tag entry in the historian, with the same path. That’s because manually changing the path doesn’t update the cache, so receiving a value with that path results in a cache miss and the historian creates a new one.  
That’s why you need to restart your historian provider after changing the path, so it can rebuild its cache.  
If you only have to do this once in a while, that’s not an issue.

---

<div class="post-metadata">

**Author:** ![Ryan\_Shaw](https://avatars.discourse-cdn.com/v4/letter/r/dbc845/32.png) [@Ryan\_Shaw](https://forum.inductiveautomation.com/u/Ryan_Shaw)\
**Post date:** [November 8, 2025, 12:15am UTC](https://forum.inductiveautomation.com/t/merge-old-tag-history-with-rename-new-tag-history/66157/14 "2025-11-08T00:15:07Z")

</div>

I just got off a call with IA support for this. During a 7.9 to 8.1.50 upgrade a new, fresh gateway was created and the screens and tags were imported from the old one. The old gateway’s historical data had partitions named like “sqlt\_data\_1\_20251030” and the new one had partitions named like “sqlt\_data\_3\_20251106”. (These are in the same database, which was kept from the old Ignition server). These are the only changes that were necessary for me:

1. Change drvid in sqlth\_scinfo to the ID in sqlth\_drv with the non-null value (i.e “default”).
2. Change drvid in sqlth\_partitions to match the ID in sqlth\_drv with the null value

I did not have to change anything else. The future partitions are sqlt\_data\_3… and use the new tagid, the old partitions are sqlt\_data\_1… and use the old tagid, and the easy chart merges them seamlessly.

We did restart the historian after making these changes, but that may not have been necessary. Important distinction: this means restarting the tag history module, not disabling and then re-enabling the tag history provider.
