Tag path changed for historian

Made a mistake. I created tags for our historian organized in one way. This created tags in the SQL database with that tag path. Manager wanted them organized another way. Same tags, just in different subfolders. Now the SQL database made new tag ID’s with the new path, and there is no link between the data before I made this change. Is there any way to bridge these so we can see them in our trend? Data is all there, but our power chart only pulls from the currently configured path, so there is no way it sees the old data.

If you're not comfortable with SQL I'd advise avoid doing this but if you are comfortable making changes then you can just fix it in SQL. Also always backup the data before you make changes.

Search the sqlth_te table and find one old tag path and one new tag path. You'll see the old and new tagid in there, note these down. Go to your sqlt_data_x_xxxx tables and search for those tag ids. You need to update the old tagid to be the new tagid for it to join the data.

Awesome, thanks! I know enough about SQL to be dangerous, and that’s how I was able to find out the tag paths were different. I should be able to handle this, and will definitely do a backup before I start.

Here's a thread as well. Though this one suggests you can also try editing the sqtlth_te table instead which if you just made the change and are fine without the new data that's easier. But if this was done a while ago and you're just noticing the data loss then you'd have to do the more manual way.

You also need to update the timestamps for the new tag ID to include the valid timespan of the old data.

Ok, I’m going to move forward with updating the sqlth_te table. From what I’m understanding I need to:

-Update the old tag paths to be the new tag path

-Update the created timestamp of the new tags to be that of the old tag

Correct?

No. Either:

  • Update tag_ids in data partitions to new tag and update new tag IDs created timestamps, OR
  • Update tag paths for old tag IDs and set old tag IDs retired timestamps

Don't forget to disable the history provider while editing the tables. Much of this data is cached in RAM and your edits won't be noticed.