How to reference a tag's path in the SQL Query on that tag

I have a Query Tag and I would like to refer to the tag’s path in the query. Is this possible? I have tried a few syntaxes but I either get null/error or just the tag’s name and not its full path.

SELECT PreviousValue 
FROM Table 
WHERE TagPath = '{[.]ThisTag.Path}'

I think the only way you could do that would be to make the tag from a UDT and then reference the UDT specific parameters for PathToTag and PathToParentFolder.


Thank you. I think for this particular project I won’t set up a UDF, but it’s good info to have for next time.

Where is the SQL reference in the UDT page you linked?

It would be a SQL Tag type in the UDT.
Create a UDT with 2 parameters
Param1 type String
Param2 type String
1 SQL Tag with the settings:
DataSource – Set to {Param1}
Query — SELECT * FROM MyTable WHERE CriteriaColumn=’{Param2}’

Then you just create the instance of the UDT and fill in the parameters.

1 Like