SQLTeam.com | Weblogs | Forums

How to execute equation stored in table


#1

I have query that return column having equation as nvarchar column
i want to execute this string to be the result of the equation for-each row
look at the return of the query

ID      Equation                             Result
1098    1300834703.69700+1197853461.64800    0
1103    1490867539.51300-0.00000	     0

thanks


#2

Can you post an example of the equation you mentioned?


#3

So do you want to update "Result" with the value returned from "Equation"? The first being 2498688165.34500?

To start I would suggest looking into split routines.


#4

You can use EXEC sp_executesql -- which has the added benefit of allowing you to use all SQL functions, such as ABS, SIGN, etc. -- but you have to run cursor through (ugh!) each equation separately, you can't really do it directly within a query.


#5

The example exits in my post
1300834703.69700+1197853461.64800
and
1490867539.51300-0.00000


#6

it is too long method
thank you


#7

Thank you for your solution i will try it