views:

178

answers:

2

I have simple table in my SQL Server Database. This table contain two columns: ID int, Name nvarchar(50). The ID column is the primary key for my table.

I want the "Name" column to be "(No Duplicates)", like in Microsoft Access, but this column isn't the primary column. How could I do this?

+11  A: 

Add a unique constraint for that column:

alter table Foo add constraint UQ_Name unique (Name)

To handle a situation where a unique constraint violation occurs, see for error 2601.

Anton Gogolev
Thank you very much. :)
Wahid Bitar
+2  A: 

You are looking for the UNIQUE constraint.

Thomas Owens