CodeWrangler
asked on
Need a UNIQUE constrain on multiple cols in a SQL Server table but one of the cols is by VALUE
Say I have this simple example table
username varchar(100),
active char(1),
date_deactivated datetime
I need to have a UNIQUE constraint on this table where there can only be one username that has active="y". There can be any number of the same username and "n" rows. Appreciate the help in advance.
username varchar(100),
active char(1),
date_deactivated datetime
I need to have a UNIQUE constraint on this table where there can only be one username that has active="y". There can be any number of the same username and "n" rows. Appreciate the help in advance.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
just curious, how much will this affect performance. I know you only have limited information about my table and it's design, but strictly from this approach of having a index use a computer column, which might be the performance impact.
Virtually zilch. There's some slight overhead to generating an identity column, but most people use one in a table anyway.
ASKER