How to use a OPC value to

I am trying to refence a tag in my queries but I keep getting weird errors. Any help would be appericated
SELECT Built
FROM View_ActiveOrders
Where Targetlineid = 50 And Orderid ='[DT Right Hand]New Tag'
One of the errors
Conversion failed when converting the varchar value '[DT Right Hand]New Tag' to data type int.

That's a string and the data column appears (from the error) to be defined as an INT.

If this is in a script then please post some context so we know where [DT Right Hand]New Tag is supposed to be coming from.

Tip: Please format code in your posts.

I was using that in the Named Queries

The Tag I am using is a refence tag which is set up as an int

Please show us how. Make it easy for us to help you. Provide details as requested.

SELECT Built
FROM View_ActiveOrders 
Where Targetlineid = 50 And Orderid = '[DT Right Hand]New Tag.value' 

First, there's no way for SQL to tell that your string constant is supposed to be a tag. You need to use a value parameter. Then where you call the named query, you retrieve and supply the tag value to the parameter.

1 Like

That's not how this works.

You need to pass the tag's value to the the named query where you're calling it.
Use a parameter in your named query (it looks like this :parameter).

https://docs.inductiveautomation.com/display/DOC81/Named+Queries

I will give this a try thank you