title: SQL Join based on code embedded in a table
body: <p>I want to use SQL stored in a field to join 2 tables RefTable and DataTable:</p>
  <p>This picture is RefTable (DataTable also has LinkFld1 and LinkFld2):</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>LinkFld1</th>
  <th>LinkFld2</th>
  <th>OutputFld</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>123</td>
  <td>like %INS%</td>
  <td>Alpha</td>
  </tr>
  <tr>
  <td>123</td>
  <td>not like %INS%</td>
  <td>Beta</td>
  </tr>
  <tr>
  <td>234</td>
  <td>like %%</td>
  <td>Gamma</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>My (non-working) code looks like this:</p>
  <pre><code>Select D.*, R.Output
  from DataTable D 
  join RefTable R
       on D.LinkFld1=R.Linkfld1 --Works as intended
       and D.linkfld2 exec(R.Linkfld2) --Doesn't work.
  </code></pre>
  <p>Intended Results:</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>DataTable.LinkFld1</th>
  <th>DataTable.LinkFld2</th>
  <th>RefTable.OutputFld</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>123</td>
  <td>INS</td>
  <td>Alpha</td>
  </tr>
  <tr>
  <td>123</td>
  <td>CON</td>
  <td>Beta</td>
  </tr>
  <tr>
  <td>234</td>
  <td>Anything</td>
  <td>Gamma</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>How do I rewrite the SQL query to use the text in LinkFld2 as <em>part of the SQL statement</em>?</p>