# How/where do I find the tagid of a tag in (vision 7.9)?

**URL:** <https://forum.inductiveautomation.com/t/how-where-do-i-find-the-tagid-of-a-tag-in-vision-7-9/95591>\
**Category:** Ignition\
**Tags:** ignition79, vision\
**Created:** [September 5, 2024, 2:24pm UTC](https://forum.inductiveautomation.com/t/how-where-do-i-find-the-tagid-of-a-tag-in-vision-7-9/95591 "2024-09-05T14:24:26Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![prashants](https://avatars.discourse-cdn.com/v4/letter/p/a87d85/32.png) [@prashants](https://forum.inductiveautomation.com/u/prashants)\
**Post date:** [September 5, 2024, 2:24pm UTC](https://forum.inductiveautomation.com/t/how-where-do-i-find-the-tagid-of-a-tag-in-vision-7-9/95591/1 "2024-09-05T14:24:26Z")

</div>

I am using this query in the report using script (vision 7.9)  
SELECT top 1 floatvalue, t\_stamp FROM sqlt\_data\_1\_2024\_08 where tagid = 1735 order by t\_stamp desc  
and I only see the data until August 28th even though the tag is working and shows the trend now.

Also how do I find the tagid for that tag? I think that would help me to update the query.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [September 5, 2024, 2:27pm UTC](https://forum.inductiveautomation.com/t/how-where-do-i-find-the-tagid-of-a-tag-in-vision-7-9/95591/2 "2024-09-05T14:27:04Z")

</div>

Why are you trying to obtain a specific tagid? What's the actual thing you're trying to do?

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [September 5, 2024, 2:28pm UTC](https://forum.inductiveautomation.com/t/how-where-do-i-find-the-tagid-of-a-tag-in-vision-7-9/95591/3 "2024-09-05T14:28:59Z")

</div>

You _can_ manually reconstruct the logic the historian uses internally, by querying across a series of tables:

> **[Ignition Database Table Reference | Ignition User Manual](https://docs.inductiveautomation.com/docs/8.1/appendix/reference-pages/ignition-database-table-reference#tag-history)**
>
> Ignition has a lot of systems built-in that will query the database automatically without requiring you to build a query. These systems automatically create the necessary tables in the database, insert the relevant data, and even query it back out...

It's not a good idea, generally.

---

<div class="post-metadata">

**Author:** ![prashants](https://avatars.discourse-cdn.com/v4/letter/p/a87d85/32.png) [@prashants](https://forum.inductiveautomation.com/u/prashants)\
**Post date:** [September 5, 2024, 2:30pm UTC](https://forum.inductiveautomation.com/t/how-where-do-i-find-the-tagid-of-a-tag-in-vision-7-9/95591/4 "2024-09-05T14:30:11Z")

</div>

There is a old script in the report (not created by me) that uses above query where tagid = 1735 and some other numbers.  
For some reason it is not showing the data after Aug 28th.

Also, I found the table sqlth\_te and wanted to see if it changed the tagid or something happened to the tag.

---

<div class="post-metadata">

**Author:** ![MMaynard](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mmaynard/32/3366_2.png) [@MMaynard](https://forum.inductiveautomation.com/u/MMaynard)\
**Post date:** [September 5, 2024, 2:50pm UTC](https://forum.inductiveautomation.com/t/how-where-do-i-find-the-tagid-of-a-tag-in-vision-7-9/95591/5 "2024-09-05T14:50:39Z")

</div>

Any time anything related to the History settings on the tag are changed, the record in sqlth\_te is retired and a new record with a new ID is created for that tag.  
Also depending on the partitioning in the DB, your source table will change as well.  
You are much better off using built in tag history query tools to get the data.

---

<div class="post-metadata">

**Author:** ![prashants](https://avatars.discourse-cdn.com/v4/letter/p/a87d85/32.png) [@prashants](https://forum.inductiveautomation.com/u/prashants)\
**Post date:** [September 5, 2024, 2:51pm UTC](https://forum.inductiveautomation.com/t/how-where-do-i-find-the-tagid-of-a-tag-in-vision-7-9/95591/6 "2024-09-05T14:51:44Z")

</div>

As suspected, it says retired on 2024-8-28 09:58:44. I searched for the tags in that table and updated the tagid and it is working now.  
I am not sure what happened, but someone updated something to those tags as the old tagid was retired and created new tagid.

---

<div class="post-metadata">

**Author:** ![MMaynard](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mmaynard/32/3366_2.png) [@MMaynard](https://forum.inductiveautomation.com/u/MMaynard)\
**Post date:** [September 5, 2024, 2:54pm UTC](https://forum.inductiveautomation.com/t/how-where-do-i-find-the-tagid-of-a-tag-in-vision-7-9/95591/7 "2024-09-05T14:54:00Z")

</div>

well you can always join the sqlth\_te table and then use the tag PATH for the query instead of the ID.

```python
SELECT        
TOP (1) floatvalue,t_stamp
FROM LatestTagPartitionTable
INNER JOIN
sqlth_te ON LatestTagPartitionTable.tagid = sqlth_te.id
WHERE
(sqlth_te.tagpath = 'Path/To/Actual/Tag') AND sqlth_te.retired IS NULL

```

The above should work for MS SQL, off the top of my head.  
Replace LatestTagPartitionTable and Path/To/Actual/Tag with your values.

Again though, if you use the built in tag history tools, you won't have to worry about retired and what table to pull from. It will UNION the old tagid with any new ones.

---

<div class="post-metadata">

**Author:** ![prashants](https://avatars.discourse-cdn.com/v4/letter/p/a87d85/32.png) [@prashants](https://forum.inductiveautomation.com/u/prashants)\
**Post date:** [September 5, 2024, 2:57pm UTC](https://forum.inductiveautomation.com/t/how-where-do-i-find-the-tagid-of-a-tag-in-vision-7-9/95591/8 "2024-09-05T14:57:54Z")

</div>

Thanks, that's what I am doing next. Using Query-Tag History to do the same thing in the script and avoid using tagid.
