I'm trying to implement a mechanism that would perform calculations based on dynamically defined algorithms. The way I do it is:
- Build a string containing the definition of all the variables along with their values,
- Fetch (from a table) the calculation formula,
- Invoke
sp_executesql
.
Here is the contents of the string passed as the calculation (contents of variable @_l_Execute_Formula
):
DECLARE @_1 FLOAT = 678;
DECLARE @_2 FLOAT = NULL;
DECLARE @_3 FLOAT = NULL;
SET @_l_Result = @_1 + @_2 + @_3
and the invocation is:
EXECUTE sp_executesql @_l_Execute_Formula ,
N'@_l_Result FLOAT OUTPUT' ,
@_l_Result = @_l_Result OUTPUT ;
I receive no error message but @_l_Result
is NULL
.
What am I doing wrong?