title: T-SQL - Tehnique for evaluation of boolean expression string
body: <p>I need to populated the 'Value' field could be '0' or '1' (false or true) depending on the expression. </p>
  
  <p>The following is simple data:</p>
  
  <pre><code>1   1 * 1 + 1   NULL
  2   0 + 0       NULL
  3   1 + 0 * 0   NULL
  4   0 * 1       NULL
  5   0 * 1 * 1   NULL
  </code></pre>
  
  <p>The 'Expression' field is of type nvarchar and contains result of conditions and boolean operators. 
  So, the data above could be formated as follows:</p>
  
  <pre><code>1   TRUE AND TRUE OR TRUE     NULL
  2   FALSE OR FALSE            NULL
  3   TRUE OR FALSE AND FALSE   NULL
  4   FALSE AND TRUE            NULL
  5   FALSE AND TRUE AND TRUE   NULL
  </code></pre>
  
  <p>In the final, the 'Expression' field could contains AND/OR and multiple TRUE and FALSE.</p>
  
  <p>What I need, as I said is to calculated the expression value - to check if it is true or false.</p>
  
  <p>The whole logic is in procedure and i can build dynamic sql for each row and excecuted it, 
  but in my real situation I will have hundres of rows, so creating loops and calling execute_sql for each row does not sound as good solution.</p>
  
  <p>Is there any build-in function that can help me to evaluted these strings as I am not able to use cross apply with procedure.</p>