title: Importing data from one table to another under conditions
body: <p>I need some help on how to proceed with this problem :</p>
  
  <p>I have the following <strong>SQL Server</strong> tables :</p>
  
  <p><strong><code>Transitions</code></strong></p>
  
  <hr>
  
  <p><code>ID</code> <em>int</em>,<br />
  <code>VariableID</code> <em>int</em>,<br />
  <code>To_VariableID</code> <em>int</em>,<br />
  <code>To_ValueID</code> <em>int</em>,<br />
  <code>To_CommentInput</code> <em>bit</em>,<br />
  <code>To_SP</code> <em>varchar</em>(255)</p>
  
  <hr>
  
  <p><strong><code>Processes</code></strong></p>
  
  <hr>
  
  <p><code>ID</code> <em>int</em>,<br />
  <code>VariableID</code> <em>int</em>,<br />
  <code>ValueID</code> <em>int</em>,<br />
  <code>Manual_Value</code> <em>varchar</em>(255)</p>
  
  <hr>
  
  <blockquote>
    <p>What applies for <strong><code>Transitions</code></strong>: Only one field among </p>
    
    <p><code>To_VariableID</code>, <code>To_ValueID</code>, <code>To_CommentInput</code>, <code>To_SP</code></p>
    
    <p>can be set at a time in each row.
    <br/>
    In some cases I want certain data from <strong><code>Transitions</code></strong> to go to <strong><code>Processes</code></strong>.</p>
  </blockquote>
  
  <p>Now, if <code>To_ValueID</code> has been set in a row in <strong><code>Transitions</code></strong>, its value should go to the <code>ValueID</code> field in the <strong><code>Processes</code></strong> table.
  If not, then the field that is filled ( don't know which one, it could be <code>To_VariableID</code>, <code>To_CommentInput</code>, <code>To_SP</code> ) should go in the <code>Manual_Value</code> field.</p>
  
  <p>Any help would be greatly appreciated!</p>