Sunday, February 12, 2012

Constraint Question

Is it possible to set an index of no duplicates on a column other than the primary key of a table? If yes, how is this done?

Yes, you can create unique index. Here is an example for creating one on a username column in Sql Server.

CREATE UNIQUE NONCLUSTERED INDEX [IX_USERNAME] ON [dbo].[USER]
(
[USERNAME] ASC
)

|||

U can use unique index. But u should not forget that unique index allows null values which we can treat them as dup values

Thank u

Baba

Please remember to click "Mark as Answer" on this post if it helped you.

No comments:

Post a Comment