patternsqlMinor
MS-SQL: unique constraint case-insensitive
Viewed 0 times
caseuniqueinsensitivesqlconstraint
Problem
How do I add a case-insensitive constraint without altering the column collation?
I've tried
and
But it won't compile...
Do I need to add a computed column to achieve this??
I've tried
CONSTRAINT [AK_User_Username_UserType] UNIQUE (LOWER([Username]) [UserType])and
CREATE UNIQUE INDEX [AK_User_Username_UserType] UNIQUE (LOWER([Username]) [UserType])But it won't compile...
Do I need to add a computed column to achieve this??
Solution
Yes a computed column would achieve this for you. Or you could create an trigger that will fire on insert or updates. Here is link to a question like yours on stackoverflow.
Context
StackExchange Database Administrators Q#105012, answer score: 2
Revisions (0)
No revisions yet.