I thought you had it until I tried to add it to a function. Then I get the error 'Invalid use of a side-effection operator 'INSERT EXEC' within a function.'.
I need to be able to use the solution in a function. The idea is that I have built a mathematical string during a query that I actually need to execute and get the results.
Thank you!