Executing SQL code within a table field
Posted on 2011-02-23
Hi All -
I have a SqlServer table that has this structure:
AccountNumber VARCHAR(50) NULL,
QRMYieldCIT DECIMAL(10,5) NULL,
TestResults DECIMAL(10,5) NULL,
Floor_Pricing_Txt_Formula VARCHAR(250) NULL,
TheFinalFormula VARCHAR(255) NULL,
CalculationResults DECIMAL(10,5) NULL
In the table field, TheFinalFormula, there contains a statement that I would like to execute within a query/stored procedure that will fill the result of the formula into the table field, CalculationResults.
Each data record has its own formula in TheFinalFormula and the formula is not generally duplicated.
Here is a sample statement that would appear in the table field, TheFinalFormula:
SELECT(CommonPrograms.dbo.cp_GreaterUDF(125*.0001,.0625) + 5.5*.01)
Note: CommonPrograms.dbo.cp_GreaterUDF is a user-defined scalar function that selects the greater of two values.
Thanks for the help!
How can I do this?