Edit for conciseness:
What I am trying to do:
Read in a tag like, 310200 from the plc, and use a query to match with X310207 from a table.
select top 1 Machine from SpecStandards
where Machine like concat('X',ltrim(substring(str({[.]model2}),1,(len(str({[.]model2}))-1))))
Gives me null instead of X310207
select concat('X',ltrim(substring(str({[.]model2}),1,(len(str({[.]model2}))-1)))) from SpecStandards
This gives me the “X31020” as a tag value.
select 1 top Machine from SpecStandards
where Machine like '%{[.]model3}%'
This will give me “X310207” which is what I want.
However, I wanted to do it with just one query tag.
select top 1 Machine from SpecStandards
where Machine like '%concat('X',ltrim(substring(str({[.]model2}),1,(len(str({[.]model2}))-1))))%'
This errors.
Finally figured it out. Needed to concat the percent symbols, and didn’t need the ‘X’.
select top 1 Machine from SpecStandards
where Machine like concat('%',ltrim(substring(str({[.]model2}),1,(len(str({[.]model2}))-1))),'%')