SQL Server 10, .NET, C#
This is similar to this question but not exactly the same.
When a user creates new event on my event-scheduling web site, a unique 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:
JohMonBlue5
<abbriviated name><abbriviated week day><some uniquefying suffix><index>
Yes, I could just e-mail a link, but I suppose that's not an option.
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.
Question: What's a good way to implement this (I have unique constraint on the column already):
- I can generate the index on the app side, and use
try { insert } catch { retry }
. In this case, how do I tell "Duplicate column value" exception from any other exception? by message text? - Use something in the MSSQL Server to increment trailing number until uniqueness reached.