I have a table containing id columns (int), boolean expression (varchar) and result (bit). The boolean expression is stored in varchar, which I need to evaluate and put the result in the result column . For example, a column may contain:
'1=1'
'2<3 AND 1^1=1'
'3>4 OR 4<2'
Then the result column should contain
1
0
0
I am currently using a cursor to navigate rows and using dynamic sql to evaluate an expression.
"IF(" + @expression + ") SET @result = 1"
Is there a better, more efficient way to do this? I would ideally want to get rid of the cursor. Any ideas? Would it be better done using assembly?
source
share