T-SQL Parse String and Perform Actions
I am exploring options to dynamically calculate values based on a string input. Take for example the following string input.

    "(32+35)/(12+34)"

The numbers 32, 35, 12, and 34 are "placeholders" for IDs. In spoken language what I am trying to do is as follows. Take the metric with ID 32 and apply some function to it which returns a value. Then add that value to the value returned by the same function applied to metric id 35, so on and so forth.

    (dbo.foo(32) + dbo.foo(35)) / (dbo.foo(12) + dbo.foo(34))

It might be easier to start with a simple addition string and work into taking other operators (-,/,*).

Is this possible in tsql? Open to regex options (have a regex tsql function) and anything else you can think of.

Perhaps a regex replace on integers to insert the function name into the string would work and then exec() the string to get a result?

Let's not argue the pros/cons of such a method...i know this is not a true "database" solution to my problem but want to explore it more.
T-SQL Parse String and Perform Actions
===

I am exploring options to dynamically calculate values based on a string input. Take for example the following string input.

    "(32+35)/(12+34)"

The numbers 32, 35, 12, and 34 are "placeholders" for IDs. In spoken language what I am trying to do is as follows. Take the metric with ID 32 and apply some function to it which returns a value. Then add that value to the value returned by the same function applied to metric id 35, so on and so forth.

    (dbo.foo(32) + dbo.foo(35)) / (dbo.foo(12) + dbo.foo(34))

It might be easier to start with a simple addition string and work into taking other operators (-,/,*).

Is this possible in tsql? Open to regex options (have a regex tsql function) and anything else you can think of.

Perhaps a regex replace on integers to insert the function name into the string would work and then exec() the string to get a result?

Let's not argue the pros/cons of such a method...i know this is not a true "database" solution to my problem but want to explore it more.