title: SQL Server generate unique value
body: <p>SQL Server 10, .NET, C#</p>
  
  <p>This is similar to <a href="https://stackoverflow.com/questions/1467581/how-to-generate-unique-id-in-mysql">this question</a> but not exactly the same.  </p>
  
  <p>When a user creates new event on my event-scheduling web site, a <strong>unique</strong> sort-of easy to remember code is to be generated, so this code can be communicated (via the phone, let's say) to the participants. This generated code looks something like:</p>
  
  <p><code>JohMonBlue5</code><br>
  <code>&lt;abbriviated name&gt;&lt;abbriviated week day&gt;&lt;some uniquefying suffix&gt;&lt;index&gt;</code></p>
  
  <p>Yes, I could just e-mail a link, but I suppose that's not an option.  </p>
  
  <p>Note: I chose to use uniquefying suffix that is a color, since I think it's easier to remember color, than a number. Still I use number in case of a collision.  </p>
  
  <p><strong>Question</strong>: What's a good way to implement this (I have unique constraint on the column already):  </p>
  
  <ol>
  <li>I can generate the index on the app side, and use <code>try { insert } catch { retry }</code>. In this case, how do I tell "Duplicate column  value" exception from any other exception? by message text?  </li>
  <li>Use something in the MSSQL Server to increment trailing number until uniqueness reached.</li>
  </ol>