title: SQL: Use the same string for both INSERT and UPDATE?
body: <p>The INSERT syntax I've been using is this</p>
  
  <pre><code>INSERT INTO TableName VALUES (...)
  </code></pre>
  
  <p>The UPDATE syntax I've been using is</p>
  
  <pre><code>UPDATE TableName SET ColumnName=Value WHERE ...
  </code></pre>
  
  <p>So in all my code, I have to generate 2 strings, which would result in something like this</p>
  
  <pre><code>insertStr = "(27, 'John Brown', 102)";
  updateStr = "ID=27, Name='John Brown', ItemID=102";
  </code></pre>
  
  <p>and then use them separately</p>
  
  <pre><code>"UPDATE TableName SET " + updateStr + " WHERE ID=27 " +
  "IF @@ROWCOUNT=0 "+
  "INSERT INTO TableName VALUES (" + insertStr + ")"
  </code></pre>
  
  <p>It starts bothering me when I am working with tables with like 30 columns.</p>
  
  <p>Can't we generate just one string to use on both INSERT and UPDATE?</p>
  
  <p>eg. using insertStr above on UPDATE statement or updateStr on INSERT statement, or a whole new way?</p>