# Using system.tag.storeTagHistory, matching to realtime tags and querying history

**URL:** <https://forum.inductiveautomation.com/t/using-system-tag-storetaghistory-matching-to-realtime-tags-and-querying-history/102847>\
**Category:** Ignition\
**Tags:** database, scripting\
**Created:** [February 25, 2025, 2:51pm UTC](https://forum.inductiveautomation.com/t/using-system-tag-storetaghistory-matching-to-realtime-tags-and-querying-history/102847 "2025-02-25T14:51:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![nathan.harris](https://avatars.discourse-cdn.com/v4/letter/n/d07c76/32.png) [@nathan.harris](https://forum.inductiveautomation.com/u/nathan.harris)\
**Post date:** [February 25, 2025, 2:51pm UTC](https://forum.inductiveautomation.com/t/using-system-tag-storetaghistory-matching-to-realtime-tags-and-querying-history/102847/1 "2025-02-25T14:51:28Z")

</div>

Hi,  
I have been using system.tag.storeTagHistory and via scripting have been using it to import data from a .csv file.

I find the imported data goes into the database fine, and matches the tagname I have created. However it always seems to retire the data I put in, and then future historical data from the tag is assigned a new id in the sqlth\_te table.

I have a SQL query to access tag historical data, so to make this easier to use I can manually update all the data I've put in to change it so the tagid is the same as the non retired tag, but I am wondering if this can be avoided.

I sort of have two questions, can the data I am inputting be assigned to the tag without getting retired?

And when using the scripting tag history access; system.tag.queryTagHistory, does this access just the current tagid history or also previous retired history (I am guessing not as why else would it be retired). Because I could look at matching multiple tagid's in the SQL query.

Hope that makes sense, and thanks in advance

---

<div class="post-metadata">

**Author:** ![nathan.harris](https://avatars.discourse-cdn.com/v4/letter/n/d07c76/32.png) [@nathan.harris](https://forum.inductiveautomation.com/u/nathan.harris)\
**Post date:** [February 26, 2025, 11:48am UTC](https://forum.inductiveautomation.com/t/using-system-tag-storetaghistory-matching-to-realtime-tags-and-querying-history/102847/2 "2025-02-26T11:48:16Z")

</div>

I am also noticing in the sqlth\_te table, the tags are being given a different query mode to the realtime tag, so I wonder if this is why it does not match the tagid.

---

<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:** [February 26, 2025, 12:52pm UTC](https://forum.inductiveautomation.com/t/using-system-tag-storetaghistory-matching-to-realtime-tags-and-querying-history/102847/3 "2025-02-26T12:52:57Z")

</div>

> [@nathan.harris](#):
>
> I have a SQL query to access tag historical data

You really should not do this. While the schema is documented, it really is an implementation detail. Use Ignition's scripting calls to run your history queries. They will handle all of the intricate details for you.
