Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 545841
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T10:48:16+00:00 2026-05-13T10:48:16+00:00

SQL Server 10, .NET, C# This is similar to this question but not exactly

  • 0

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):

  1. 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?
  2. Use something in the MSSQL Server to increment trailing number until uniqueness reached.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T10:48:16+00:00Added an answer on May 13, 2026 at 10:48 am

    I suggest not using the catch to handle your duplicates exclusively. Catch should only be used for true errors and besides that, exception catching is slow and expensive. It would be better to generate a value and test to see whether it already exists via a query rather than allowing an exception to get thrown.

    I would also implement the generator in one place. Don’t split it by creating a color on the client and the number in the db. Pick one side or the other. On the Sql Server side a good way of implementing this type of feature is to use a UDF. Perhaps you can create a table of keywords (colors in your case) and randomly select from it and then perform your increment for uniqueness.

    I also think that you don’t have to o colors exclusively. Choose any words that are simple and easy to remember. Dragon, Friday, Blue, House…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 261k
  • Answers 261k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The Net tab of the FireBug Addon for FireFox provides… May 13, 2026 at 11:30 am
  • Editorial Team
    Editorial Team added an answer If you add a new() constraint, you can create an… May 13, 2026 at 11:30 am
  • Editorial Team
    Editorial Team added an answer Use a regex: RegexKitLite Here's a complete example using the… May 13, 2026 at 11:30 am

Related Questions

If I have a collection of database tables (in an Access file, for example)
During my apprenticeship, I have used NHibernate for some smaller projects which I mostly
Two questions: Can someone point me to unbiased data that compares .NET performance to
Ok, I'm using SQL Server Express 2008 and .Net 3.5 (c#) I have a
FYI - I am a mainframer that moved to the .NET world a couple

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.