Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Create unique field that isn't the key

Author  Topic 

Pinto
Aged Yak Warrior

590 Posts

Posted - 2005-11-10 : 06:44:29
I have a table where the key is an autonumber. I also have a field which holds the reference of a room eg 0BM1. It is nvarchar. Is there a way I can set this field to duplicates = No, so that my user cannot enter the same room reference more than once. Or do I have to do this check in my asp.net code ?

TIA

LarsG
Constraint Violating Yak Guru

284 Posts

Posted - 2005-11-10 : 06:47:33
Seems like you want a unique constraint


alter table tableName add constraint constraintName unique(columnName)

Go to Top of Page
   

- Advertisement -