George George

George George

  • NA
  • 778
  • 0

smarter ways to make a column value unique

Jan 14 2009 8:02 AM

Hello everyone,

I have a table and a couple of columns in this table. For some specific column, it is not primary key, but I want to accept only unique value for this specific column for each row.

Currently, my naive solution is to use a store procedure to handle table insertion and if in the store procedure I find there is already a row whose existing value for the specific column is the same as the new column value of the new row to be inserted, I will return error from the store procedure and refuse to insert the whole new row.

Any other smarter ways?

thanks in advance,
George


Answers (2)