This is an oversimplified example of something I'm trying to build. The real #Dynamic table might have 10 to 20 rows of formulas. What I'm trying to do is build a stored procedure using multiple row/fields from a table. Thanks.
--assume these tables exist
CREATE TABLE #Desired (CustomerId varchar(20), NetIncome numeric(11,2), Ratio numeric(11,2), NotUsed int)
CREATE TABLE #Dynamic (NewField varchar(20), MyFormula varchar(99))
INSERT INTO #Dynamic
SELECT 'NetIncome', 'Revenue - Expense' UNION ALL
SELECT 'Ratio', 'Revenue / Expense'
--desired result is to build a stored procedure using multiple row/fields from a table
INSERT INTO #Desired (CustomerId, NetIncome, Ratio)
SELECT CustomerId, Revenue - Expense as NetIncome, Revenue / Expense as Ratio FROM #RawData