I am trying to evaluate an expression in a function, and it happens that XQuery is not able to get string from the SQL variable
DECLARE @XML AS XML = ''
DECLARE @Formula AS NVARCHAR(MAX) = '1+1'
SELECT @XML.query(@Formula)
Using ...
SELECT @XML.query('sql:variable("@Formula")')
... just returns a string 1+1
, and not the sum.
Is there a way to make this work in SQL (without using stored procedures, because those will not run form within the function)?
Thanks in advance!