Tag Query - Getting String Values using Tags as Parameters

I have this SQL scalar function on a Query tag which has the parameters @location and @level.

I have these tags called:

  1. location (as memory tag string) - with the value '0788'
  2. level - as float

my query tag contains the query:

DECLARE @location VARCHAR(50) = CONVERT(VARCHAR(50), {[.]../location.value});
DECLARE @Level FLOAT = {[.]../level.value};
SELECT dbo.fx_CalculateVolume(@location, @Level);

which basically grabs the tag values and use it as a parameter to the function. But I am receiving a NULL value.

But when I try this:

DECLARE @location VARCHAR(50) = '0788'
DECLARE @Level FLOAT = {[.]../level.value};
SELECT dbo.fx_CalculateVolume(@location, @Level);

I am getting a returned value. I was wondering if there is something I'm missing or a property from ignition from the conversion to string using the tag value.

try single quotes around it?

DECLARE @location VARCHAR(50) = 'CONVERT(VARCHAR(50), {[.]../location.value})'