unique username in user table

peanutong
08-25-2008, 02:50 AM
how do i create restrictions whereby there cannot be two similar username in the table, while registering?

i am using SQL server.

thank you.

gpraceman
08-25-2008, 08:15 AM
Just run a query to verify that the new user name doesn't already exist in the table first, then do the insert.

wayneph
08-25-2008, 08:35 AM
It's better to add a Constraint on the table so that SQL doesn't allow the second occurance in. A Primary or Unique Constraint on the Username column should do the trick in this case.

What happens when there are multiple developers on a project and not everyone codes the same checks in? I'm not saying that the application shouldn't check to see if it's there, but the responsibility for clean data should be held in the database design.

gpraceman
08-25-2008, 08:42 AM
What happens when there are multiple developers on a project and not everyone codes the same checks in? I'm not saying that the application shouldn't check to see if it's there, but the responsibility for clean data should be held in the database design.
So true.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum