Declare @InputA decimal(20,4)
Declare @InputB decimal(20,4)
Declare @InputFormula nVarchar (500)
Declare @Result decimal(20,4)
Set @InputA=1 --This will be passed into the function
Set @InputB=3 --This will be passed into the function
Set @InputFormula='@InputA+@InputB' --Ultimately this will be passed into the function as a string
/* here is the code */
Set @InputFormula = ' SELECT @res = ' + @InputFormula
EXEC sp_executesql @inputFormula, N'@InputA decimal(20,4), @inputB decimal(20,4), @res decimal(20,4) OUTPUT ', @InputA, @inputB, @result OUTPUT
Print @Result --Expecting to See 4
|