Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Easiest way to make a column unique
Message
General information
Forum:
Microsoft SQL Server
Category:
Database design
Miscellaneous
Thread ID:
00620370
Message ID:
00621291
Views:
14
>What is the easiest way to make column unique?
>
>I created a unique index on the field but I really dont need the index, so the overhead of the managing the index seems excessive. Is there any other way to make a column unique? Im thinking some sort of check constraint that does a select but I get an error every time I use a query in a check constraint.
>
>Any ideas?
>
>Eric

From the BOL:

"SQL Server automatically creates a UNIQUE index to enforce the uniqueness requirement of the UNIQUE constraint. Therefore, if an attempt to insert a duplicate row is made, SQL Server returns an error message that says the UNIQUE constraint has been violated and does not add the row to the table. Unless a clustered index is explicitly specified, a unique, nonclustered index is created by default to enforce the UNIQUE constraint."

You complain about overhead... but, whould you rather have SQL Scan the whole table each time you add/update a record to make sure the value is unique?
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform