I have a table that is holding user defined calculation formulas and another table that holds the values. I need to inject the value into the calculation formula to be able to evaluate the formula and return the result.
Example formula that is in a column row called Calculation formula in the Formulas table
(310165)/(7248+7249)
These numbers represent corresponding ValueID's in the Values table
ValueID | Value
7248 | 18521
7249 | 3835
310165 | 68546.24
I need to find a way with SQL to inject the Value into the formula in the Formulas table by matching up with the ValueID in the Values table.
I have looked at replace and stuff and for xml path and I cant seem to find a way to get this done. After this is done I then need to evaluate the expression that has been produced with the actual values to return an int value. Any help is greatly appreciated.