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

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

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.

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.