Retrieving Tag Information with an SQL Query

I am writing a stored precedure which will retrieve data from a table which is populated by a transaction group. For all the tags in the transaction group, their value is stored every 15 minutes.
The stored procedure will retrieve, for example, the average value for each tag during the period. The result set is to be tagname, average value, tooltip & units (e.g. m3/hr or deg C), with one row per tag.
I have no problem getting the first two values, but is there anywhere I can use SQL to get the Engineering Units and tooltip given the tagname?

I did look in the Console->Advanced section, and the query “SELECT * FROM SQLTAGPROP” seems to give me the data I want, but I don’t see that table anywhere in the SQL Server I’m using.

I suspect the answer may be because I’m using the default Internal Tags provider. Can I query this from SQL? How can I connect to it?
Or should I be using a “Database Driving Provider” and storing my tags there?
If I do this how difficult (or advisable) is it to change over my tags to this from the default provider?

Hi,

Yes, if the tags were stored in the database, you could get to their properties by querying the meta table (“sqlt_meta” in external sqltags). You cannot get to the internal database from outside.

I assume the EUs will be static, and how often does the tooltip change? If the answer is never, I wouldn’t recommend switching your whole tag system over just to get to that information through our structure. Instead, I would recommend setting up your own “lookup table”, where you map that tag id (can be whatever is easiest for you to identify the tag with) to the engineering units and tooltip you want.

If you have more compelling reasons to get to the actual tag data in the database, including modifying tags from outside or custom screens, you can try switching over to the driving provider. The easiest way to do that is basically to create the provider, do a CSV export from your internal provider, and import it to your new provider. You’ll then need to edit all of the tags (use the “tag search” button) to set the “driver name” to the name you specified when you set up the driving provider (“ignition” by default). This could also be done in the csv before importing it.

But, like I said before, if I were just trying to link some static information, I would set up those tables by hand in the database instead of switching away from the internal provider.

Regards,

Thanks Colby. I think that’s the way we will go.