title: T-SQL cursor and update
body: <p>I use a cursor to iterate through quite a big table. For each row I check if value from one column exists in other.</p>
  
  <p>If the value exists, I would like to increase value column in that other table.
  If not, I would like to insert there new row with value set to 1.</p>
  
  <p>I check "if exists" by:</p>
  
  <pre><code>IF (SELECT COUNT(*) FROM otherTabe WHERE... &gt; 1)
     BEGIN
        ...
     END
  ELSE
     BEGIN
        ...
     END
  </code></pre>
  
  <p>I don't know how to get that row which was found and update value. I don't want to make another select.</p>
  
  <p>How can I do this efficiently?</p>
  
  <p>I assume that the method of checking described above isn't good for this case.</p>